下面的代码显示错误,好像文件不存在。我可以找到该chromedriver.exe
文件,但该.exe
文件似乎不可执行。
这些是我的命令:
System.setProperty("webdriver.chrome.driver","driver = webdriver.Chrome(executable_path='/usr/local/share/chromedriver')");
WebDriver driver = new ChromeDriver();
driver.get("https://www.youtube.com/");
什么可能导致这种功能障碍?
答案1
您可以使用chromium-chromedriver
:
sudo apt-get install chromium-chromedriver
或下载专有 ChromeDriver并使用它:
wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
unzip chromedriver_linux64.zip
./chromedriver
您需要安装 selenium python 包:
sudo apt-get install python-selenium python3-selenium
它与谷歌的开始使用 Python 程序:
import time
from selenium import webdriver
driver = webdriver.Chrome('./chromedriver') # Optional argument, if not specified will search path.
# or '/usr/lib/chromium-browser/chromedriver' if you use chromium-chromedriver
driver.get('http://www.google.com/xhtml');
time.sleep(5) # Let the user actually see something!
search_box = driver.find_element_by_name('q')
search_box.send_keys('ChromeDriver')
search_box.submit()
time.sleep(5) # Let the user actually see something!
driver.quit()