问题
I imported webdriver from selenium and os. I want to be able to run this piece of code successfully:
driver = webdriver.Chrome(executable_path= os.path.abspath('') + '/chromedriver')
The error I'm getting:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81
I'm using python 2.7 on a MAC OSX. I have version 81.0.4044.138 of the chromedriver installed from https://sites.google.com/a/chromium.org/chromedriver/downloads in the same workspace directory, and it is named 'chromedriver', but it's like my webdriver doesn't recognize it. I would appreciate any suggestions!
回答1:
This is happening in most cases due to differences between the Chrome web driver version and the Chrome Browser version.
I would suggest you to do the following: 1- Take a backup of your work. 2- Update Chrome Browser to the latest version. 3- Install the latest version of the chrome browser. 4- Kill any chromedriver process that is running in the background. 5- Clean up your code and give it a try.
回答2:
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 81
...implies that the ChromeDriver was unable to initiate/spawn a new Browsing Context i.e. Chrome Browser session.
Analysis
Your main issue is the incompatibility between the version of the binaries you are using as follows:
- You are using ChromeDriver 81.0
- Release Notes of ChromeDriver 81.0 clearly mentions the following :
Supports Chrome version 81
Most probhably the Chrome Browser got updated to Chrome v83.0 as a part of the recent push.
- Release Notes of ChromeDriver v83.0 clearly mentions the following :
Supports Chrome version 83
- Your Selenium Client version is unknown to us.
So there is a clear mismatch between ChromeDriver v81.0 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.
- Execute your
@Test
as non-root user.
来源:https://stackoverflow.com/questions/61969692/sessionnotcreatedexception-message-session-not-created-this-version-of-chrome