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
    – GPT14
    CommentedMay 17, 2018 at 11:39
  • Java can't understand ~ is user home folder, only Linux Shell know it represents user home folder.
    – yong
    CommentedMay 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

0
    1

    You have to set the Path :

    driver = webdriver.Chrome('C:/path/to/chromedriver.exe') 
    5
    • Unfortunatey, i've tried and get the same sort of error: No such file or directory: '~/drivers/chromedriver': '~/drivers/chromedriver'
      – Dannydjrs
      CommentedMay 17, 2018 at 11:12
    • how you are giving the path . share your code pleaseCommentedMay 17, 2018 at 11:13
    • 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 machineCommentedMay 17, 2018 at 11:31
    • I'm using Python 3.6.5 on windows 10 and chrom-driver version is 2.38 and chrome version is 66CommentedMay 17, 2018 at 11:31
    • there is something wrong with your path check once !CommentedMay 17, 2018 at 11:34
    0

    download selenium server-standalone-3.12.0.jar

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

      Start asking to get answers

      Find the answer to your question by asking.

      Ask question

      Explore related questions

      See similar questions with these tags.