I am trying to get selenium to open a site and I don't really have any errors in my PyCharm editor but when I run my code I am getting a lot of errors I do not really understand it would be nice to get some help
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Chrome(executable_path=r"C:\chromedriver\chromedriver.exe")
driver.get("https://www.singaporetech.edu.sg/") # get gets url
print(driver.title) # title of the page
driver.close()
This is the error I get:
C:\Users\kaush\PycharmProjects\seleniumTest1\venv\Scripts\python.exe C:/Users/kaush/PycharmProjects/seleniumTest1/main.py
Traceback (most recent call last):
File "C:\Users\kaush\PycharmProjects\seleniumTest1\main.py", line 4, in <module>
driver = webdriver.Chrome(executable_path=r"C:\chromedriver\chromedriver.exe")
File "C:\Users\kaush\PycharmProjects\seleniumTest1\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\kaush\PycharmProjects\seleniumTest1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\kaush\PycharmProjects\seleniumTest1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\kaush\PycharmProjects\seleniumTest1\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\kaush\PycharmProjects\seleniumTest1\venv\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 87
Current browser version is 86.0.4240.198 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
Conclusion # To solve the Selenium error "WebDriverException: Message: 'chromedriver' executable needs to be in PATH", install and import the webdriver-manager module by running pip install webdriver-manager . The module simplifies management of binary drivers for different browsers.
Specifically: ChromeDriver uses the same version number scheme as Chrome. See https://www.chromium.org/developers/version-numbers for more details. Each version of ChromeDriver supports Chrome with matching major, minor, and build version numbers.
This error message...
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version 87
Current browser version is 86.0.4240.198 with binary path C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
...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:
Supports Chrome version 87
So there is a clear mismatch between ChromeDriver v2.40 and the Chrome Browser v85.0
Ensure that:
@Test
as non-root user.driver.quit()
within tearDown(){}
method to close & destroy the WebDriver and Web Client instances gracefully.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With