Skip to content

You cannot reuse the ChromeOptions object #3054

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
eze2286 opened this issue Aug 25, 2024 · 1 comment
Closed

You cannot reuse the ChromeOptions object #3054

eze2286 opened this issue Aug 25, 2024 · 1 comment
Labels
duplicate The answer/solution already exists somewhere UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode

Comments

@eze2286
Copy link

eze2286 commented Aug 25, 2024

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:

from seleniumbase import SB

with SB(uc=True, test=True) as sb:
    url = "https://gitlab.com/users/sign_in"
    sb.uc_open_with_reconnect(url, 4)
    sb.uc_gui_click_captcha()
    sb.assert_text("Username", '[for="user_login"]', timeout=3)
    sb.assert_element('label[for="user_login"]')
    sb.highlight('button:contains("Sign in")')
    sb.highlight('h1:contains("GitLab.com")')
    sb.post_message("SeleniumBase wasn't detected", duration=4)

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

@mdmintz mdmintz added duplicate The answer/solution already exists somewhere UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode labels Aug 25, 2024
@mdmintz
Copy link
Member

mdmintz commented Aug 25, 2024

Duplicate of #3027 (comment)

@mdmintz mdmintz marked this as a duplicate of #3027 Aug 25, 2024
@mdmintz mdmintz closed this as completed Aug 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate The answer/solution already exists somewhere UC Mode / CDP Mode Undetected Chromedriver Mode / CDP Mode
Projects
None yet
Development

No branches or pull requests

2 participants