You cannot reuse the ChromeOptions object #3054
Labels
duplicate
The answer/solution already exists somewhere
UC Mode / CDP Mode
Undetected Chromedriver Mode / CDP Mode
Getting the following error when trying to run my script with UC Mode scripts on headless Linux machines. In my case I run this in EC2 instance in AWS. Ubuntu and Linux instance, in both cases raise the similar error:
MY CODE:
ERROR:
Traceback (most recent call last):
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 4286, in get_local_driver
driver = undetected.Chrome(
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/undetected/init.py", line 316, in init
super().init(options=options, service=service_)
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/chrome/webdriver.py", line 45, in init
super().init(
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/chromium/webdriver.py", line 66, in init
super().init(command_executor=executor, options=options)
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 212, in init
self.start_session(capabilities)
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/undetected/init.py", line 479, in start_session
super().start_session(capabilities)
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 299, in start_session
response = self.execute(Command.NEW_SESSION, caps)["value"]
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/webdriver.py", line 354, in execute
self.error_handler.check_response(response)
File "/home/ec2-user/.local/lib/python3.9/site-packages/selenium/webdriver/remote/errorhandler.py", line 229, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: cannot connect to chrome at 127.0.0.1:9222
from chrome not reachable
Stacktrace:
#0 0x55d581c3081a
#1 0x55d5818fec91
#2 0x55d5818ea93f
#3 0x55d58193c813
#4 0x55d5819324bc
#5 0x55d58197f64e
#6 0x55d58197ee66
#7 0x55d581973233
#8 0x55d581941093
#9 0x55d58194209e
#10 0x55d581bf7a7b
#11 0x55d581bfba31
#12 0x55d581be3645
#13 0x55d581bfc5a2
#14 0x55d581bc881f
#15 0x55d581c1f618
#16 0x55d581c1f7e2
#17 0x55d581c2f60c
#18 0x7f6744a9f7f2 start_thread
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/ec2-user/test.py", line 3, in
with SB(uc=True, test=True) as sb:
File "/usr/lib64/python3.9/contextlib.py", line 119, in enter
return next(self.gen)
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/plugins/sb_manager.py", line 986, in SB
sb.setUp()
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/fixtures/base_case.py", line 14916, in setUp
self.driver = self.get_new_driver(
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/fixtures/base_case.py", line 4101, in get_new_driver
new_driver = browser_launcher.get_driver(
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 2339, in get_driver
return get_local_driver(
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/core/browser_launcher.py", line 4304, in get_local_driver
driver = undetected.Chrome(
File "/home/ec2-user/.local/lib/python3.9/site-packages/seleniumbase/undetected/init.py", line 136, in init
raise RuntimeError("You cannot reuse the ChromeOptions object")
RuntimeError: You cannot reuse the ChromeOptions object
The text was updated successfully, but these errors were encountered: