0

I am trying to open Chromium with Selenium using PyCharm. This is my code:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.binary_location = '/usr/bin/chromium-browser'

chrome_driver_binary = '/opt/WebDriver/bin/chromedriver'
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
driver.get('http://google.com/')

And I get an error in line starting with 'driver = '

selenium.common.exceptions.WebDriverException: Message: unknown error: no chrome binary at /usr/bin/chromium-browser

Actually, in /usr/bin there is a thing called chromium-browser, an executable file.

I also tried this solution from Set chrome browser binary through chromedriver in Python, but no better:

from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
cap = DesiredCapabilities.CHROME
cap = {'binary_location': '/usr/bin/chromium-browser'}
driver = webdriver.Chrome(desired_capabilities=cap, executable_path='/opt/WebDriver/bin/chromedriver')
driver.get('http://google.com/')

gives:

selenium.common.exceptions.WebDriverException: Message: unknown error: cannot find Chrome binary

Any help? Third hour googling over it ;)

Naeredie
  • 1
  • 3

1 Answers1

0

In a terminal do a which chromedriver.

I would expect that would return path /usr/bin/chromedriver, although whatever the returned path, that's the one to use as executable_path.

You might need to force the raw string like:

chrome_driver_binary = r'/usr/bin/chromedriver'
0buz
  • 3,443
  • 2
  • 8
  • 29
  • I've done it, but output is No such file or directory: '/usr/local/bin/chromedriver': '/usr/local/bin/chromedriver', and then 'During handling of the above exception, another exception occurred:' 'chromedriver' executable needs to be in PATH. – Naeredie May 01 '20 at 16:54