0

I try to run chromedriver in this way :

options = Options()
options.add_argument("--headless")
browser = webdriver.Chrome(options=options, service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])
browser.get("whatever-url.com")
soup = BeautifulSoup(browser.page_source, 'html.parser')
browser.implicitly_wait(2)
browser.close()
browser.quit()
text_file = open("Output.html", "w") # Write html content on this file for debug purpose
text_file.write(str(soup))
text_file.close()
print("ok")

But everytime, I stumble on this error:

...
FileNotFoundError: [Errno 2] No such file or directory: 'chromedriver'
...
selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH.

While chromedriver is very well installed. Here is why : enter image description here enter image description here

And running dpkg -l | less give me a bit of this: enter image description here

I run Python 3.5, Selenium 3.11 and Chromedriver 2.37 on Ubuntu 16 with a virtualenv.

What's wrong :( ?

Please help

Community
  • 1
  • 1
kabrice
  • 1,475
  • 6
  • 27
  • 51
  • Please, my post is about Chromedriver, not PhantomJS. Any way, I've tried to use Chromedrive path in this way `browser = webdriver.Chrome(executable_path='/usr/local/bin/chromedriver', options=options, service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])`, still get the same error. – kabrice Apr 01 '18 at 19:14
  • Anyway, the option is the same https://seleniumhq.github.io/selenium/docs/api/py/webdriver_chrome/selenium.webdriver.chrome.webdriver.html#module-selenium.webdriver.chrome.webdriver – Alexey Dolgopolov Apr 01 '18 at 19:17
  • `browser = webdriver.Chrome(executable_path='/path/to/chromedriver', options=options, service_args=['--ignore-ssl-errors=true', '--ssl-protocol=any'])` – Alexey Dolgopolov Apr 01 '18 at 19:19
  • Already tried this (look my last comment), and I still get the same error – kabrice Apr 01 '18 at 19:20
  • Does chromedriver have executable rights? What'll you get if you start chromedriver in console inside virtualenv? – Alexey Dolgopolov Apr 01 '18 at 19:28
  • Please how to check if chromedriver has executable? (I'm a newbie in those stuff). – kabrice Apr 01 '18 at 19:33
  • `ls -l /usr/local/bin/chromedriver` then if permissions have an`x` (rwx, or r-x) then it's executable. – Alexey Dolgopolov Apr 01 '18 at 19:38
  • Also, you can try to put chromedriver in another directory. I store mine in the /opt/chromdriver/ folder – Alexey Dolgopolov Apr 01 '18 at 19:39
  • OK, yes I think it's executable. Here's what I have : `lrwxrwxrwx 1 root root 54 Apr 1 17:50 /usr/local/bin/chromedriver -> /usr/local/share/chromedriver_linux64/bin/chromedriver` – kabrice Apr 01 '18 at 19:40
  • @AlexeyDolgopolov I've tried to move in another directory and I get this `error: selenium.common.exceptions.WebDriverException: Message: unknown error: Chrome failed to start: crashed` – kabrice Apr 01 '18 at 19:49
  • Ok, looks like a progress. Maybe your environment prevented to find chromedriver. Now you may start logging it. Add these to `service_args=["--verbose", "--log-path=webdriver.log"]` And look at the log after crash – Alexey Dolgopolov Apr 01 '18 at 20:13
  • Still get the error :( – kabrice Apr 01 '18 at 20:17
  • Now what does the log say? You may enable logging in Chromium https://www.chromium.org/for-testers/enable-logging. `options.add_argument('--enable-logging') options.add_argument('--log-level=1')` And look in chrome log in the user data directory (in the /tmp folder) – Alexey Dolgopolov Apr 01 '18 at 20:22
  • Possible duplicate of [Running Chromedriver on Ubuntu Server headlessly](https://stackoverflow.com/questions/49500700/running-chromedriver-on-ubuntu-server-headlessly) – undetected Selenium Apr 01 '18 at 21:02
  • @AlexeyDolgopolov, I've enabled the logging and I can't see logging file in `/tmp` :( – kabrice Apr 01 '18 at 21:21
  • @DebanjanB your SO post doesn't work for me :( – kabrice Apr 01 '18 at 21:23
  • I've just reinstalled `google-chrome`, and it works now – kabrice Apr 01 '18 at 22:45

0 Answers0