0

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'
2
  • I think you are not setting your path right. Try using export PATH=$PATH:/place/with/the/file without the curly braces and the quotes Commented May 17, 2018 at 11:39
  • Java can't understand ~ is user home folder, only Linux Shell know it represents user home folder. Commented May 17, 2018 at 13:26

3 Answers 3

2

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

Sign up to request clarification or add additional context in comments.

Comments

1

You have to set the Path :

driver = webdriver.Chrome('C:/path/to/chromedriver.exe')

5 Comments

Unfortunatey, i've tried and get the same sort of error: No such file or directory: '~/drivers/chromedriver': '~/drivers/chromedriver'
how you are giving the path . share your code please
this is my script : from selenium import webdriver driver = webdriver.Chrome('F:\\Automation\\chromedriver.exe') driver.get("gmail.com") and it is working on my machine
I'm using Python 3.6.5 on windows 10 and chrom-driver version is 2.38 and chrome version is 66
there is something wrong with your path check once !
0

download selenium server-standalone-3.12.0.jar

and try this in a terminal: export CLASSPATH=".:selenium-server-standalone-3.12.0.jar"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.