I have a problem, every, single, TIME
Basically this is my code:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
options = Options()
options.binary_location = "C:\Program Files (x86)\Google\Chrome Beta\Application\chrome.exe"
options.add_argument("--no-sandbox")
options.add_argument("--no-default-browser-check")
options.add_argument("--no-first-run")
options.add_argument("--disable-default-apps")
driver = webdriver.Chrome(options=options, executable_path="C:\Program Files (x86)\Google\Chrome Beta\Application\chromedriver.exe")
driver.get('https://www.youtube.com/')
and the error is
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
I used Pycharm and tried to use VS code with python 3.4 and 3.7 and 3.8.3
plz help me I'm getting tired of this.
Full error Log:
Traceback (most recent call last):
File "C:/Users/um/PycharmProjects/Selenium/main.py", line 10, in <module>
driver = webdriver.Chrome(options=options, executable_path="C:\Program Files (x86)\Google\Chrome Beta\Application\chromedriver.exe")
File "C:\Users\um\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 76, in __init__
RemoteWebDriver.__init__(
File "C:\Users\um\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\um\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\um\AppData\Local\Programs\Python\Python38-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\um\AppData\Local\Programs\Python\Python38-32\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
from disconnected: unable to send message to renderer
(Session info: chrome=81.0.4044.83)
Your error is not
unable to send message to renderer
as you mentioned. According to the stack trace you posted the problem in the line 6
driver = webdriver.Chrome(options=options, executable_path="chromedriver.exe", )
and the problem is:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created
It seems like you specified an invalid path to the chromedriver and Selenium is unable to initialize the driver and create a session.
You should also check the version of the chromedriver with the guide.
Here you can download the valid version (I have taken your Chrome version from the stacktrace).
yes it did start and then close with the error log above, and also i have the correct version
Related
I'm trying to open website in my real Chrome not a driver But i got list of Errors and it does't open the url**
Here is my code
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
s = Service("C:\\Users\\Administrator\\Desktop\\chromedriver.exe")
options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=C:\\Users\\Administrator\\AppData\\Local\\Google\\Chrome\\User Data")
options.add_argument('--profile-directory=Default')
driver = webdriver.Chrome(service=s, chrome_options=options)
driver.get("https://www.instagram.com")
The Errors Like :
C:\Users\Administrator\Desktop\Py Sele\Sele.py:11: DeprecationWarning: use options instead of chrome_options
driver = webdriver.Chrome(service=s, chrome_options=options)
Opening in existing browser session.
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\Py Sele\Sele.py", line 11, in <module>
driver = webdriver.Chrome(service=s, chrome_options=options)
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 70, in __init__
super(WebDriver, self).__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\chromium\webdriver.py", line 93, in __init__
RemoteWebDriver.__init__(
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 268, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 359, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 424, in execute
self.error_handler.check_response(response)
File "C:\Program Files\Python39\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
Stacktrace:
Backtrace:
This error message...
selenium.common.exceptions.InvalidArgumentException: Message: invalid argument: user data directory is already in use, please specify a unique value for --user-data-dir argument, or don't use --user-data-dir
...implies that the --user-data-dir is already in use.
Your main issue is you have already an open Google Chrome browser session opened for your manual browsing.
There is no such error in your code block. However it seems you are executing program as an Administrator. But,
A common cause for Chrome to crash during startup is running Chrome as root user (administrator) on Linux. While it is possible to work around this issue by passing --no-sandbox flag when creating your WebDriver session, such a configuration is unsupported and highly discouraged. You need to configure your environment to run Chrome as a regular user instead.
Solution
Before you execute your test as an user e.g. Administrator, ensure that you don't have any open Chrome browser windows using the same user i.e. Administrator.
I am working on a web application, and was attempting to run a basic test script with seleium, just to make sure my code was working
from selenium import webdriver
import time
import os
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument("--test-type")
options.binary_location = os.getcwd()
driver = webdriver.Chrome(chrome_options=options, executable_path=r'./chromedriver')
driver.get('http://codepad.org')
I have the chromedriver in the current directory, and I think I am using the correct version of the chromedriver (75.0.3770.90). The full error I am getting is:
Traceback (most recent call last):
File "test.py", line 9, in <module>
driver = webdriver.Chrome(options=options, executable_path=r'./chromedriver')
File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/chrome/webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "/Users/kylerood/Documents/summer19/makeFriends/env/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create a Chrome process.
If anyone has any insight into a fix I could try that would be greatly appreciated!
Remove/comment the below line.
options.binary_location = os.getcwd()
As the binary is not located in the current working directory you are getting this error message.
binary_location is the location where your chrome.exe is located.
And make sure you have the chromedriver in the same folder you have this test located. Otherwise your script will fail with below error message.
selenium.common.exceptions.WebDriverException: Message: 'chromedriver` executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
The value binary_location must be an .exe file which specify the chrome.exe you want to run.
So this code works for me:
chrome_options = Options()
chrome_options.binary_location = '****\\chrome.exe'
driver = webdriver.Chrome(executable_path=os.path.abspath("chromedriver\\chromedriver.exe"), options=chrome_options)
Hope it helps you
This question already has answers here:
WebDriverException: unknown error: DevToolsActivePort file doesn't exist while trying to initiate Chrome Browser
(44 answers)
Closed 4 years ago.
I made a python script that scrapes information and clicks a few buttons and it works great on chrome webdriver, but as soon as I try to enter it as headless it does nothing for a few seconds and then gives an error. My code is below.
options = Options()
options.headless = True
options.add_argument("user-data-dir=selenium")
browser = webdriver.Chrome(executable_path=r'C:\Users\REDACTED\Desktop\REDACTED\browser\chromedriver.exe', options=options)
browser.get('https://REDACTED')
And here's the error
Traceback (most recent call last):
File "C:/Users/REDACTED/PycharmProjects/Test/REDACTED.py", line 49, in <module>
browser = webdriver.Chrome(executable_path=r'C:\Users\REDACTED\Desktop\REDACTED\browser\chromedriver.exe', options=options)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\REDACTED\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: DevToolsActivePort file doesn't exist
(Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90),platform=Windows NT 10.0.17134 x86_64)
What works for me when I use selenium with chrome is:
you can try options.add_argument('--headless') as your method brings up an error (only for chrome, no error for firefox)
another thing you can try is removing the .exe from your executable_path. When i add .exe i get a the same error you got.
Here's my code and the error Python provides.
I'm a beginner using Python 3.6. Can anyone helps find out what's wrong? Many thanks.
#!/usr/bin/env python
#coding: utf-8
from selenium import webdriver
driver = webdriver.Chrome('C:\\Users\\Admin\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe')
browser = webdriver.Chrome()
browser.get('http://www.bing.com/')
Traceback:
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\cxy61.com - html\python spider\001 selenium import.py", line 8, in <module>
driver = webdriver.Chrome('C:\\Users\\Admin\\AppData\\Local\\Google\\Chrome\\Application\\chromedriver.exe')
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 140, in __init__
self.start_session(desired_capabilities, browser_profile)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 229, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 297, in execute
self.error_handler.check_response(response)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python36\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception: Chrome version must be >= 58.0.3029.0
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.14393 x86_64)
You have to take care of a couple of things as follows:
As you are using chromedriver v2.31 the error clearly states Chrome version must be >= 58.0.3029.0. So you need to bump up your Google Chrome version to v58.0 or above.
If you want to specify the absolute path of the chromedriver within single quotes '...' then you have to provide single forward slashes \ only.
If you are assigning the webdriver instance to the driver, you have to use the driver instance only to open any url
Here is your own code with the above mentioned changes:
from selenium import webdriver
driver = webdriver.Chrome(r'C:\Utility\BrowserDrivers\chromedriver.exe')
driver.get('http://www.bing.com/')
I am using python3 on mac os and I have updated chrome, chromedriver and selenium to the latest version. I am getting a TimeoutException, the browser opens correctly but it freezes.
>>> from selenium import webdriver
>>> driver = webdriver.Chrome()
# opens browser with blank page
>>> driver.get('http://example.com')
# gets first page OK and then driver literally flashes once
>>> driver.get('http://stackoverflow.com')
>>>
# Cursor loading forever... until TimeoutException
This error is thrown:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 248, in get
self.execute(Command.GET, {'url': url})
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message: timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -0.003
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.0 x86_64)
I'm using: Python 3.5.2 ,Chrome 54.0, chromedriver 2.25, selenium 3.0.1
I've tried other versions of chromedriver with no success, also I did not find any solution to this online. Thanks.
EDIT:
Still getting the error from above + getting a new error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
self.start_session(desired_capabilities, browser_profile)
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
response = self.execute(Command.NEW_SESSION, capabilities)
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
self.error_handler.check_response(response)
File "/usr/local/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: session not created exception
from unknown error: bad inspector message: {"method":"Page.loadEventFired","params":{"timestamp":14220,088073}}
(Session info: chrome=54.0.2840.71)
(Driver info: chromedriver=2.25.426935 (820a95b0b81d33e42712f9198c215f703412e1a1),platform=Mac OS X 10.12.0 x86_64)
selenium.common.exceptions.TimeoutException: Message: timeout: cannot determine loading status
from timeout: Timed out receiving message from renderer: -0.003
Issue817:It looks like this issue has been logged as a bug for Selenium.
Someone has answered to get rid from this issue by using the --dns-prefetch-disable option of chrome.
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument('--dns-prefetch-disable')
driver = Chrome(chrome_options=chrome_options)
If issue still exists follow this thread may be it solves your problem
Set
env LANG=en_US.UTF-8 ./chromedriver
from : https://bugs.chromium.org/p/chromedriver/issues/detail?id=1552