lxndrbnsv
lxndrbnsv

Reputation: 33

Python/Selenium/Chromedriver: the script opens just a blank Google Chrome page

I have a problem with a browser automation script on a specific windows 7 machine. The code is written in python 3.7.4 with Selenium and Chromedriver. When I run it from a command line only Chrome browser starts but it does not open the url. This problem occurs only on one windows 7 machine and I can't figure out its reason. I've tried to run the script with both disabled firewall and antivirus, but unfortunately these measures don't help. Also there are no any error output in the command line.

I thought that something is preventing the script from connecting to the internet but python scripts with urllib.request run without any problems.

The script works fine on Fedora 30 and Debian 10. I've also tested it on windows 10 and windows 7 via Gnome Boxes: everything was ok.

The original code is about 3 000 lines, so here's a small sample I've written from scratch:

from selenium import webdriver

browser = webdriver.Chrome(executable_path = 'webdriver/chromedriver.exe')
print('Starting')
browser.get('https://google.com')

So when I run the script, nothing happens besides the opening of a blank page in Chrome. And "print" is not executed too.

I've stored "browser" variable in separate file. When I run the script with this variable in the same file I've got the following error message:

DevTools listening on ws://127.0.0.1:27046/devtools/browser/1ecf2c8f-c0cb-44d7-9
27d-cfa3901f645b
Traceback (most recent call last):
File "test-no-conf.py", line 5, in <module>
executable_path = 'webdriver/chromedriver.exe'
File "C:\Users\К\AppData\Local\Programs\Python\Python37\lib\site-packages\sele
nium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\К\AppData\Local\Programs\Python\Python37\lib\site-packages\sele
nium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\К\AppData\Local\Programs\Python\Python37\lib\site-packages\sele
nium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\К\AppData\Local\Programs\Python\Python37\lib\site-packages\sele
nium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\К\AppData\Local\Programs\Python\Python37\lib\site-packages\sele
nium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not crea
ted
from disconnected: Unable to receive message from renderer
(Session info: chrome=77.0.3865.120)

Thank you in advance.

Upvotes: 3

Views: 2286

Answers (2)

Naveen
Naveen

Reputation: 788

Check the Chrome browser version you have installed in the machine and compare it with the Chrome driver version.

You can learn more about these changes here and download latest drivers here.

In particular these instructions:

"Here are the steps to select the version of ChromeDriver to download: First, find out which version of Chrome you are using. Let's say you have Chrome 72.0.3626.81.

Take the Chrome version number, remove the last part, and append the result to URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_". For example, with Chrome version 72.0.3626.81, you'd get a URL "https://chromedriver.storage.googleapis.com/LATEST_RELEASE_72.0.3626".

Use the URL created in the last step to retrieve a small file containing the version of ChromeDriver to use. For example, the above URL will get your a file containing "72.0.3626.69". (The actual number may change in the future, of course.)

Use the version number retrieved from the previous step to construct the URL to download ChromeDriver. With version 72.0.3626.69, the URL would be "https://chromedriver.storage.googleapis.com/index.html?path=72.0.3626.69/".

After the initial download, it is recommended that you occasionally go through the above process again to see if there are any bug fix releases."

If this doesn't resolve this error, make sure all previous chrome and driver instances are closed.

Upvotes: 1

lxndrbnsv
lxndrbnsv

Reputation: 33

I've reinstalled the system and now everything works. It seems that the system on that particular machine had some problems.

Upvotes: 0

Related Questions