下面的程式碼顯示錯誤,就好像該檔案不存在一樣。我可以找到該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
它可以與 Google 一起使用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()