I'm in the process of updating Selenium and chromedriver for automated testing purposes. I updated chromedriver and Chrome to version 98, and I went from Selenium v.3.3.3 to 4.1.0.
But I'm getting an unknown error whenever I try and run my test scripts now. The entire traceback is below:
C:\sw\src\Presentation\client\TestAutomationScripts\TestAutomationScripts\TestPlans>python TestPlan_ATO.py
Traceback (most recent call last):
File "TestPlan_ATO.py", line 9, in <module>
class TestPlan_ATO():
File "TestPlan_ATO.py", line 11, in TestPlan_ATO
testPlan = Test(name="TestPlan_ATO")
File "C:\sw\src\Presentation\client\TestAutomationScripts\TestAutomationScripts\TestPlans\TestCases\Test.py", line 113, in __init__
self.driver = WebDriverInstance().driver
File "..\Util\WebDriverInstance.py", line 43, in __call__
cls._instances[cls] = super(Singleton, cls).__call__(*args, **kwargs)
File "..\Util\WebDriverInstance.py", line 97, in __init__
driver = driverModule(executable_path=driverPath)
File "..\Util\WebDriverInstance.py", line 73, in createChromeDriver
driver = webdriver.Chrome(desired_capabilities=capabilities)
File "C:\Anaconda\lib\selenium\webdriver\chrome\webdriver.py", line 73, in __init__
service_log_path, service, keep_alive)
File "C:\Anaconda\lib\selenium\webdriver\chromium\webdriver.py", line 99, in __init__
options=options)
File "C:\Anaconda\lib\selenium\webdriver\remote\webdriver.py", line 269, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Anaconda\lib\selenium\webdriver\remote\webdriver.py", line 360, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Anaconda\lib\selenium\webdriver\remote\webdriver.py", line 425, in execute
self.error_handler.check_response(response)
File "C:\Anaconda\lib\selenium\webdriver\remote\errorhandler.py", line 247, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Failed to create Chrome process.
Stacktrace:
Backtrace:
Ordinal0 [0x00317AC3+2587331]
Ordinal0 [0x002AADD1+2141649]
Ordinal0 [0x001A3BB8+1063864]
Ordinal0 [0x001BF684+1177220]
Ordinal0 [0x001BCC51+1166417]
Ordinal0 [0x001ED12F+1364271]
Ordinal0 [0x001ECD5A+1363290]
Ordinal0 [0x001E84A6+1344678]
Ordinal0 [0x001C53F6+1201142]
Ordinal0 [0x001C62E6+1204966]
GetHandleVerifier [0x004BDF22+1680738]
GetHandleVerifier [0x00570DBC+2413564]
GetHandleVerifier [0x003AD151+563089]
GetHandleVerifier [0x003ABF13+558419]
Ordinal0 [0x002B081E+2164766]
Ordinal0 [0x002B5508+2184456]
Ordinal0 [0x002B5650+2184784]
Ordinal0 [0x002BF5BC+2225596]
BaseThreadInitThunk [0x75A4FA29+25]
RtlGetAppContainerNamedObjectPath [0x77107A9E+286]
RtlGetAppContainerNamedObjectPath [0x77107A6E+238]
(No symbol) [0x00000000]
I have Chrome on my PATH, but that doesn't seem to make a difference. Under the 'Compatibility' tab in Chrome properties, I've checked 'Run this program as administrator' but, again, that didn't work. I'm not sure what else to do.
Edit 1:
The Anaconda distribution sits on my C drive. The selenium directory is inside the Anaconda directory. When I updated selenium, I got ModuleNotFoundError: 'certifi' in the traceback:
Traceback (most recent call last):
File "TestPlan_ATO.py", line 2, in <module>
from TestCases.Test import Test
File "C:\sw\src\Presentation\client\TestAutomationScripts\TestAutomationScripts\TestPlans\TestCases\Test.py", line 72, in <module>
from Util.WebDriverEventListener import WebDriverEventListener as Listener
File "..\Util\WebDriverEventListener.py", line 25, in <module>
from selenium.webdriver.support.events import AbstractEventListener
File "C:\Anaconda\lib\selenium\webdriver\__init__.py", line 18, in <module>
from .firefox.webdriver import WebDriver as Firefox # noqa
File "C:\Anaconda\lib\selenium\webdriver\firefox\webdriver.py", line 24, in <module>
from selenium.webdriver.remote.webdriver import WebDriver as RemoteWebDriver
File "C:\Anaconda\lib\selenium\webdriver\remote\webdriver.py", line 39, in <module>
from .remote_connection import RemoteConnection
File "C:\Anaconda\lib\selenium\webdriver\remote\remote_connection.py", line 26, in <module>
import certifi
ModuleNotFoundError: No module named 'certifi'
So to fix this error, I went into remote_connection.py and added the first two lines below to the file.
import sys
sys.path.append('/Anaconda/Lib/site-packages/pip/_vendor')
import logging
import socket
import string
import os
import certifi
import urllib3
import platform
I then got another error complaining about testcase.ini, which is the config file that contains the IPs of the systems under test, the login information for the app, etc.
Cannot load C:\Anaconda\Lib\site-packages\pip\_vendor\TestPlans\TestCases\testcase.ini
Traceback (most recent call last):
File "TestPlan_ATO.py", line 5, in <module>
from TestCases.ATO.TestCase_ATO import TestCase_ATO
File "C:\sw\src\Presentation\client\TestAutomationScripts\TestAutomationScripts\TestPlans\TestCases\ATO\TestCase_ATO.py", line 22, in <module>
from Util.UiOps import UiOps as ops
File "..\Util\UiOps.py", line 37, in <module>
class UiOps:
File "..\Util\UiOps.py", line 40, in UiOps
config.load('','testcase.ini')
File "..\Util\ConfigManager.py", line 114, in load
new_dict: dict = self.loader.loadFile(package=package, module=module, filename=filename)
File "..\Util\ConfigLoader.py", line 96, in loadFile
raise IOError('Cannot load ' + config_file)
OSError: Cannot load C:\Anaconda\Lib\site-packages\pip\_vendor\TestPlans\TestCases\testcase.ini
testcase.ini is read every time an automated test is run. The ConfigLoader class returns a config object given a module name and file path relative to ConfigLoader. So I go into ConfigLoader.py and I change the -1s in the try/except block below to -2s:
try:
if self.package:
#If a package is given, use the last entry in sys.path which goes up a directory, and drill down into the package
path = sys.path[-2] + "//" + self.package
else:
#If not, use the information stored in sys.path, and assume we want to look in TestPlans/TestCases
path = sys.path[-2] + "//TestPlans//TestCases"
And that is how I arrived at the Unknown Error which I first posted about.
testcase.ini is also where the browser is selected and the driver path is stored. It looks like this:
; parameters for test framework
[TEST]
DRIVER_PATH = C:\Anaconda\
BROWSER = CHROME
; BROWSER = EDGE
; BROWSER = FIREFOX
CHROME_PATH = C:\Program Files\Google\Chrome\Application\chrome.exe
; EDGE_PATH = C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
; FIREFOX_PATH = C:\Program Files\Mozilla Firefox\firefox.exe
There were two copies of chrome.exe, one in Program Files and another in Program Files (x86). I don't know why there are two separate Google directories in two different C drive subdirectories.
Anyway, I deleted the Google directory in Program Files and kept the one in (x86), and now my test scripts run again.
Related to the solution Trevor discovered, this error may also be caused by the presence of new_chrome.exe within the application's own directory.
The issue affects some other chromium browsers or versions (Brave [106.0.5249.103]; where I had encountered a similar error – CoCreate ProcessLauncherClass failed), but seemingly not all (Microsoft Edge [106.0.1370.42]; could not replicate the issue).
Either way, removal of the substitute executable resolves the error without further issue.
Related
On Replit normal selenium works fine but undetected chromedriver (the python library) doesn't seem to work, here's my code:
import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get('https://google.com')
I keep getting this error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
driver = uc.Chrome()
File "/home/runner/fff/venv/lib/python3.8/site-packages/undetected_chromedriver/__init__.py", line 401, in __init__
super(Chrome, self).__init__(
File "/home/runner/fff/venv/lib/python3.8/site-packages/selenium/webdriver/chrome/webdriver.py", line 69, in __init__
super().__init__(DesiredCapabilities.CHROME['browserName'], "goog",
File "/home/runner/fff/venv/lib/python3.8/site-packages/selenium/webdriver/chromium/webdriver.py", line 89, in __init__
self.service.start()
File "/home/runner/fff/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 98, in start
self.assert_process_still_running()
File "/home/runner/fff/venv/lib/python3.8/site-packages/selenium/webdriver/common/service.py", line 110, in assert_process_still_running
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: Service /home/runner/.local/share/undetected_chromedriver/9366826a81e09122_chromedriver unexpectedly exited. Status code was: 127
Does anyone know how to fix it? Please help, thanks so much!
Unable to load the web page using seleniumwire, I am observing this error in the browser.
This page isn't working
xxx.xyz didn't send any data.
ERR_EMPTY_RESPONSE
When I replace seleniumwire with selenium while initializing the webdriver, the issue is no longer observed.
Seleniumwire was working fine and the below-mentioned error started occurring a couple of days ago.
Seleniumwire version: 4.4.0
Python 3.9
MacOS Big Sur
AttributeError: module 'lib' has no attribute 'SSL_CTX_get0_param'
ERROR:seleniumwire.server:127.0.0.1:61095: Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/server.py",
line 113, in handle root_layer() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/modes/http_proxy.py",
line 9, in call layer() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py",
line 285, in call layer() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http1.py",
line 100, in call layer() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py",
line 206, in call if not self._process_flow(flow): File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py",
line 285, in _process_flow return self.handle_regular_connect(f) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/http.py",
line 224, in handle_regular_connect layer() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py",
line 278, in call self._establish_tls_with_client_and_server() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py",
line 358, in _establish_tls_with_client_and_server self._establish_tls_with_server() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/server/protocol/tls.py",
line 445, in _establish_tls_with_server self.server_conn.establish_tls( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/connections.py",
line 295, in establish_tls self.convert_to_tls(cert=client_cert, sni=sni, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/net/tcp.py",
line 382, in convert_to_tls context = tls.create_client_context( File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/seleniumwire/thirdparty/mitmproxy/net/tls.py",
line 285, in create_client_context param = SSL._lib.SSL_CTX_get0_param(context._context)
AttributeError: module 'lib' has no attribute 'SSL_CTX_get0_param'
This looks like you are using an outdated version of the cryptography library.
/usr/local/bin/python3.9 /Users/rabbu/PycharmProjects/pythonProject/seleniumpkg/Basic.py
Traceback (most recent call last):
File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/common/service.py", line 72, in start
self.process = subprocess.Popen(cmd, env=self.env,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 947, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 1819, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: '../drivers.chromedriver'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/rabbu/PycharmProjects/pythonProject/seleniumpkg/Basic.py", line 4, in <module>
driver = webdriver.Chrome(executable_path="../drivers.chromedriver")
File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/chrome/webdriver.py", line 73, in __init__
self.service.start()
File "/Users/rabbu/Library/Python/3.9/lib/python/site-packages/selenium/webdriver/common/service.py", line 81, in start
raise WebDriverException(
selenium.common.exceptions.WebDriverException: Message: 'drivers.chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home
Process finished with exit code 1
You can use webdriver_manager to directly download and launch the driver without providing the path.
You can install by using webdriver_manager by using pip3 install webdriver_manager
from webdriver_manager.chrome import ChromeDriverManager
from selenium import webdriver
driver = webdriver.Chrome(executable_path=ChromeDriverManager().install())
driver.get("Your URL")
I am attempting to automate a web browser using the environment below:
Windows10, Selenium (v3.141.0), Python (v3.7.4) chrome (v77.0.3865.90), and chromedriver (v77.0.3865.40). I installed pip, installed Selenium(using Python), set my paths in the environmental variables, called out the path to my chromedriver, and I still am running into issues.
-path using for chromedriver: "C:\webdrivers\chromedriver.exe"
-path to Python: "C:\Users\linds\AppData\Local\Programs\Python\Python37"
I have some code that I ran below with errors. Any ideas?
>>> from selenium import webdriver
>>> from selenium.webdriver.chrome.options import Options
>>> options = Options()
>>> options.add_argument('--headless')
>>> options.add_argument('--no-sandbox')
>>> options.add_argument('--disable-gpu')
>>> driver = webdriver.Chrome(options=options, executable_path='C:\webdrivers\chromedriver.exe')
Traceback (most recent call last):
File "<pyshell#31>", line 1, in <module>
driver = webdriver.Chrome(options=options, executable_path='C:\webdrivers\chromedriver.exe')
File "C:\Users\linds\AppData\Local\Programs\Python\Python37\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 81, in __init__
desired_capabilities=desired_capabilities)
File "C:\Users\linds\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\linds\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\linds\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\linds\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: Failed to create a Chrome process.
When attempting to run Selenium Webdriver tests with IE, the browser will launch but immediately crash with the error "Command line server for the IE driver has stopped working".
The scripts where IE fails run just fine in Chrome and Firefox.
Windows 10 IE 11.15.16299.0
Python 3.6.3 (tried with Python 2.7.14)
32-bit IEDriverServer.exe version 3.5.0.0
I followed the setup instructions at
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
Here's what Python reports:
Traceback (most recent call last):
File "tc_131.py", line 34, in <module>
driver.set_page_load_timeout(30)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 814, in set_page_load_timeout
'pageLoad': int(float(time_to_wait) * 1000)})
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 306, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 464, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 526, in _request
resp = opener.open(request, timeout=self._timeout)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 526, in open
response = self._open(req, data)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 544, in _open
'_open', req)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 504, in _call_chain
result = func(*args)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1346, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\urllib\request.py", line 1321, in do_open
r = h.getresponse()
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 1331, in getresponse
response.begin()
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 297, in begin
version, status, reason = self._read_status()
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 258, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "C:\Users\brent\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host
The simplest test causes the failure:
from selenium import webdriver
driver = webdriver.Ie()
driver.set_page_load_timeout(30)
driver.get('https://google.com')
driver.implicitly_wait(30)
I had the similar problem yesterday:
At first I tried to run with 64-bit IEDriverServer.exe version 3.9.0.0 and also had ConnectionResetError: [WinError 10054]
And then I download 32-bit IEDriverServer 3.9 from here https://www.seleniumhq.org/download/
And my script now is working and IE runs good (even without setting "executable_path" (added to PATH) and time sleeping):
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
#driver = webdriver.Ie(executable_path="C:\\webdrivers\\IEDriverServer.exe")
driver = webdriver.Ie()
#driver.set_script_timeout(5.0)
#time.sleep(3)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
time.sleep(5)
driver.close()
Maybe, you need update version of IEDriverServer to 3.9
And my python version is higher 3.6.5
Also I added both register keys (for 32-bit and 64-bit path) as mentioned in the setup instruction:
https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver#required-configuration
I hope this will help...
I had a similar problem but I am using c# had a read here https://github.com/SeleniumHQ/selenium/issues/6085 and this solved my problem You might need to read through the discussion
driver.FindElement(By.XPath("(//input[#id='Submit'])[2]")).Click();
My understanding is in IE the above syntax is not working but you might want to use this instead
IWebElement submit = driver.FindElement(By.XPath("(//input[#id='Submit'])[2]"));
OpenQA.Selenium.Interactions.Actions buildersub = new OpenQA.Selenium.Interactions.Actions(driver);
OpenQA.Selenium.Interactions.Actions hoverClicksub = buildersub.MoveToElement(submit).MoveByOffset(5, 5).Click();
hoverClicksub.Build().Perform();