I'm running a Python script on Ubuntu that uses Selenium and Chromedriver.
Here's the code:
options = webdriver.ChromeOptions()
options.add_argument('--no-sandbox')
options.add_argument('--window-size=1420,1080')
options.add_argument('--headless')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
options.add_argument("--disable-notifications")
options.add_experimental_option('useAutomationExtension', False)
options.binary_location='/usr/bin/google-chrome-stable'
chrome_driver_binary = "/usr/bin/chromedriver"
driver = webdriver.Chrome(chrome_driver_binary, chrome_options=options)
After reading about this error, I realize it may be due to incompatibility between chromedriver and the version of of chrome I'm using.
chromedriver -v
gives me:ChromeDriver 79.0.3945.130
google-chrome-stable -version
gives me:Google Chrome 78.0.3904.70
chromium-browser -version
gives me:Chromium 79.0.3945.130
However, when I set the binary location to be chromium-browser, I still get the same error.
Both chromedriver, chromium-browser, and google-chrome-stable are in /usr/bin
. 2 questions:
Should the above code theoretically work if Chromedriver and Chrome are the same version? Why would chromium-browser throw an error if it's same version as Chromedriver?
In command-line, How can I update google-chrome / google-chrome-stable to match the specific Chromedriver version? Looking for best-practice here on how to easily keep these both synched to the same version of each other. I could probably run
sudo apt-get upgrade google-chrome-stable
but how do I know this will give me the correct Chrome version to match Chromedriver?