3

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.

frianH
  • 7,295
  • 6
  • 20
  • 45
lxndrbnsv
  • 33
  • 5
  • share the script, please – rok Oct 20 '19 at 09:45
  • please read [mcve] and edit your question accordingly – Dev Oct 20 '19 at 09:47
  • Thank you. I've added an example of code to the post. It's not the actual code I ran on those machine. But I wrote several small code samples (like that one) to test if the script would work, and it failed to get the url. – lxndrbnsv Oct 20 '19 at 10:13
  • And it seems strange to me that browser opens before the print statement. – lxndrbnsv Oct 20 '19 at 10:21

2 Answers2

1

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.

Dr. H. Lecter
  • 478
  • 2
  • 5
  • 16
Naveen
  • 770
  • 10
  • 22
  • Thank you. But unfortunately it doesn't work. Both chrome and chromedriver versions are 77, and all processes of chrome, chromedriver and chromium had been terminated before launching the script. I think that it may be a problem with a specific windows 7 version on that machine. Seems that I have to reinstall the OS. – lxndrbnsv Oct 20 '19 at 12:27
  • What is the version of Selenium module? – Naveen Oct 20 '19 at 15:44
  • It's Selenium 3.141.0 – lxndrbnsv Oct 20 '19 at 16:21
  • Then it should work. Can you try uninstalling and reinstalling Selenium, Python, Chrome and see if it resolves it? – Naveen Oct 20 '19 at 19:20
  • I've tried it already, but thank you anyway. I wonder if there may be any system components which may conflict with Selenium. – lxndrbnsv Oct 20 '19 at 19:41
0

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

lxndrbnsv
  • 33
  • 5