I've been attempting to use the selenium webdriver with Google Chrome. I have installed chromedriver, and set the path to it. This has been done correctly as when I run chromedriver in terminal I get the output
Starting ChromeDriver 2.38.552518
on port 9515
Only local connections are allowed
However, when I attempt to use the chromedriver on my python script:
from selenium import webdriver
driver = webdriver.Chrome()
I get this following error:
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver': 'chromedriver'
I've tried multiple methods of specifying the direct path and also putting the chromedriver file in the folder the python script is in. But nothing seems to be working and they all give the same error!
Please Help!
edit:
Path has been set in bash profile as such:
export PATH="~/drivers/:${PATH}"
Attempted Path specified in the python script as such:
driver = webdriver.Chrome("~/drivers/chromedriver")
Still with the same error of:
No such file or directory: '~/drivers/chromedriver': '~/drivers/chromedriver'
Java can't understand ~/drivers/chromedriver
, Because only Linux Shell understand ~
is user home folder, But Java can't.
So your should use absolute path like /home/<userA>/drivers/chromedriver
or relative path like ../drivers/chromedriver
您必须设置Path:
driver = webdriver.Chrome('C:/path/to/chromedriver.exe')
download selenium server-standalone -3.12.0.jar
and try this in a terminal: export CLASSPATH=".:selenium-server-standalone-3.12.0.jar
"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.