Python selenium WebDriverException: chrome not reachable while opening ChromeDriver - python

I am using Selenium Chrome Webdriver to open a webpage in Python 3.
I would like to have a function that can open the webpage.
I originally had:
driver = webdriver.Chrome(executable_path=r'C:\Users\alice\Desktop\chromedriver')
driver.get('https://reports.blm.gov/report/LR2000/23/Pub-MC-Geo-Index')
I put it in to a function goTo()
def goTo():
driver = webdriver.Chrome(executable_path=r'C:\Users\alice\Desktop\chromedriver')
driver.get('https://reports.blm.gov/report/LR2000/23/Pub-MC-Geo-Index')
However, I was unable to do any other action on that page outside of that goTo function. When try I get error:
WebDriverException: chrome not reachable
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
Does anyone knows how can I open the a page properly using a function?

The error says it all :
WebDriverException: chrome not reachable
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.35.528161 (5b82f2d2aae0ca24b877009200ced9065a772e73),platform=Windows NT 10.0.16299 x86_64)
Your main issue is the version compatibility between the binaries you are using as follows :
You are using chromedriver=2.35
Release Notes of chromedriver=2.35 clearly mentions the following :
Supports Chrome v62-64
You are using chrome=65.0
Release Notes of ChromeDriver v2.36 clearly mentions the following :
Supports Chrome v64-66
So there is a clear mismatch between the ChromeDriver version (v2.35) and the Chrome Browser version (v65.0)
Solution
Upgrade Selenium to current levels Version 3.11.0.
Upgrade ChromeDriver to current ChromeDriver v2.37 level.
Keep Chrome version at Chrome v65.x levels. (as per ChromeDriver v2.37 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Related

Python script crashes after opening selenium Chrome web driver in a specific profile

I am using python to open chrome web driver in a specific profile as follows:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = webdriver.ChromeOptions()
options.add_argument(r'user-data-dir=C:\Users\retro\AppData\Local\Google\Chrome\User Data')
options.add_argument('--profile-directory=Profile 1')
driver = webdriver.Chrome(r'chromedriver.exe', options=options)
The script trying to run it shows the following error stack. However the window is opened in Chrome in the profile I wanted and it stays open in there!
Full Error Stack:
WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.20180 x86_64)
EDIT 1:
I have added following two options as well which some solutions suggested but still no use:
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
And I have made sure that I'm using right webdriver version i.e. 84 which matches my chrome version. When I try with latest version it throws an error that the driver version is only usable with chrome version 85.
EDIT 2:
I have added port number as well:
options.add_argument("--remote-debugging-port=9222")
Adding which although result in same outcome, it changes error stack as follows:
WebDriverException: Message: unknown error: Chrome failed to start: crashed
(chrome not reachable)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.20180 x86_64)
This error message...
WebDriverException: Message: unknown error: Chrome failed to start: crashed
(unknown error: DevToolsActivePort file doesn't exist)
(The process started from chrome location C:\Program Files (x86)\Google\Chrome\Application\chrome.exe is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
(Driver info: chromedriver=2.42.591088 (7b2b2dca23cca0862f674758c9a3933e685c27d5),platform=Windows NT 10.0.20180 x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.42
Release Notes of chromedriver=2.42 clearly mentions the following :
Supports Chrome v68-70
Possibly you are using the latest chrome=84.0
Release Notes of ChromeDriver v84.0 clearly mentions the following :
Supports Chrome version 84
So there is a clear mismatch between ChromeDriver v2.42 and the Chrome Browser v84.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v84.0 level.
Chrome is updated to current Chrome Version 84.0 level. (as per ChromeDriver v84.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

executionContextCreated has invalid 'context' error running Selenium and ChromeDriver in Jupyter notebook

Code below:
from selenium import webdriver
EXE_PATH = r'C:\Users\chris\Downloads\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(executable_path=EXE_PATH)
driver.get('https://google.com')
Error Message even though I set my path:
executionContextCreated has invalid 'context': {"auxData":{"frameId":"EF256666E4D81997909BDF6BF23E3170","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=83.0.4103.116)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 10.0 x86_64)
This error message...
executionContextCreated has invalid 'context': {"auxData":{"frameId":"EF256666E4D81997909BDF6BF23E3170","isDefault":true,"type":"default"},"id":1,"name":"","origin":"://"}
(Session info: chrome=83.0.4103.116)
(Driver info: chromedriver=2.15.322448 (52179c1b310fec1797c81ea9a20326839860b7d3),platform=Windows NT 10.0 x86_64)
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
You are using chromedriver=2.15
Release Notes of chromedriver=2.15 clearly mentions the following :
Supports Chrome v40-43
You are using chrome=83.0
Release Notes of ChromeDriver v83.0 clearly mentions:
Supports Chrome version 83
So there is a clear mismatch between ChromeDriver v2.15 and the Chrome Browser v83.0
Solution
Ensure that:
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v83.0 level.
Chrome is updated to current Chrome Version 83.0 level. (as per ChromeDriver v83.0 release notes)
If your base Web Client version is too old, then uninstall it and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test as non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.

Message: Unable to find a matching set of capabilities error using Selenium and GeckoDriver while loading on live server

I have to build an web application on a linux webserver that will use selenium with firefox . When I run the application the the linux server "localhost:5000" it works perfectly fine . But when i tried it with "127.0.0.1:80" it is not giving me an error during webdriver loading:
driver = webdriver.Firefox(executable_path='/usr/local/bin/geckodriver')
Error:
"Message: Unable to find a matching set of capabilities"
In nginx access.log it is producing a http 200 and there is nothing on error.log
in geckodriver.log it produce:
Listening on port 41209
Environment details:
selenium = 3.8.0
geckodriver = 0.18.0
Firefox version 53
python = 3.6
nginx imageApp.conf
server {
listen 80;
server_name 127.0.0.1;
location / {
include proxy_params;
proxy_pass http://unix:/home/administator/imageDetectionApplication/imageDetectionApplication.sock;
}
}
imageDetectionApplication.service
I am completely new in linux server...!!
This error message...
Message: Unable to find a matching set of capabilities
...implies that the GeckoDriver was unable to initiate/spawn a new Browsing Context i.e. Firefox Browser session.
Your main issue is the incompatibility between the version of the binaries you are using as follows:
Your Selenium Client version is 3.8.0 which is almost 2.5 years older.
Your JDK version is unknown to us.
Your GeckoDriver version is 0.18.0 which is older.
Your Firefox version is 53 which is also pretty old.
So there is a clear mismatch between the Selenium Client v3.8.0 , GeckoDriver v0.18.0 and the Firefox Browser v53
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u251.
Selenium is upgraded to current levels Version 3.141.59.
GeckoDriver is upgraded to GeckoDriver v0.26.0 level.
Firefox is upgraded to current Firefox v72.0 levels.
GeckoDriver is present in the desired location.
GeckoDriver is having executable permission for non-root users.
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
If your base Web Client version is too old, then uninstall it install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your Test as a non-root user.
Always invoke driver.quit() within tearDown(){} method to close & destroy the WebDriver and Web Client instances gracefully.
References
You can find a couple of relevant discussions in:
Selenium “Unable to find a matching set of capabilities” despite driver being in /usr/local/bin
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities with Firefox 46 through Selenium
Selenium WebDriver, Firefox, Centos, unable to find a matching set of capabilities
Unable to find a matching set of capabilities with selenium 3.4.3, firefox 54.0 and gecko driver 0.17
selenium.common.exceptions.SessionNotCreatedException: Message: Unable to find a matching set of capabilities with GeckoDriver, Selenium and Firefox

Driver info: driver.version: unknown with ChromeDriver Chrome using Selenium and Python

It is showing timed out for driver server to start when I use chrome driver.
And when I try to use Firefox it is showing session unexpectedly exited.
I am trying to run the Remote driver on a server using selenium in python
what should I do?
Unable to create new session.
UnknownError: Timed out waiting for driver server to start.
Build info: version: '3.141.0', revision: '2ecb7d9a', time: '2018-10-31T20:22:52'
System info: host: 'server.*******.com', ip: '61.16.155.6', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-862.11.6.el7.x86_64', java.version: '1.8.0_201'
Driver info: driver.version: unknown
This error message...
Driver info: driver.version: unknown
...implies that the ChromeDriver wasn't recognized back by the Browsing Context i.e. Chrome browser.
Solution
Ensure that:
JDK is upgraded to current levels JDK 8u222.
Selenium is upgraded to current levels Version 3.141.59.
ChromeDriver is updated to current ChromeDriver v78.0 level.
Chrome is updated to current Chrome Version 78.0 level. (as per ChromeDriver v78.0 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Reference
You can find a detailed discussion on version compatibility in:
How to work with a specific version of ChromeDriver while Chrome Browser gets updated automatically through Python selenium

Selenium and Chrome Compatibility (v67 + 2.38 chromedriver)

I am currently trying to run a python program on my linux box. I keep getting this error:
I am using Chrome version 67 and Selenium chromedriver of 2.38. Which I thought were compatible? Any ideas what I am doing wrong?
selenium.common.exceptions.SessionNotCreatedException: Message: session not created exception
from disconnected: Unable to receive message from renderer
(Session info: chrome=67.0.3396.62)
(Driver info: chromedriver=2.38.552522 (437e6fbedfa8762dec75e2c5b3ddb86763dc9dcb),platform=Linux 3.13.0-92-generic x86_64)
As per your error stack trace as you are using chromedriver=2.38 and chrome=67.0 this issue must not have arised.
Even the discussion Get a "WebDriverException: disconnected: unable to receive message from renderer" error when switching browser windows doesn't provides any proper conclusion. However you can try a couple of upgrade/cleanup steps as follows:
Upgrade Selenium to current levels Version 3.12.0.
Keep ChromeDriver to current ChromeDriver v2.38 level.
Keep Chrome version at Chrome v67.x levels. (as per ChromeDriver v2.38 release notes)
Clean your Project Workspace through your IDE and Rebuild your project with required dependencies only.
Use CCleaner tool to wipe off all the OS chores before and after the execution of your test Suite.
If your base Web Client version is too old, then uninstall it through Revo Uninstaller and install a recent GA and released version of Web Client.
Take a System Reboot.
Execute your #Test.
You will find similar discussions in:
Automation Testing Error : org.openqa.selenium.WebDriverException: disconnected: unable to connect to renderer
Error [SEVERE]: Timed out receiving message from renderer: 20.000 while executing the testsuite through Selenium on Jenkins

Categories