-
Notifications
You must be signed in to change notification settings - Fork 1.4k
-
I am currently writing a program in Python which uses a Seleniumbase web bot, however, during the running of the program, I am encountering a mysterious error.
Some of the code is as follows:
from seleniumbase import SB
with SB(uc=True, test=True, xvfb=True, incognito=True, agent=<user_agent>, headless=False) as sb:
url = "https://invideo.io/perf/ga-ai-video-generator-web/?utm_source=google&utm_medium=cpc&utm_campaign=Top16_Search_Brand_Exact_EN&adset_name=InVideo&keyword=invideo&network=g&device=c&utm_term=invideo&utm_content=InVideo&matchtype=e&placement=g&campaign_id=18035330768&adset_id=140632017072&ad_id=616240030555&gad_source=1&gclid=Cj0KCQiAvvO7BhC-ARIsAGFyToWFf0L_8iqkB32qg9prKxVApsklZ8HA69LW2O0Z6XC1nbXXz9sCTTEaAinZEALw_wcB"
sb.activate_cdp_mode(url)
sb.sleep(5)
signup_button = sb.cdp.find_element('//button[@class="iv-inline-block iv-text-body-xl iv-text-black-50 iv-font-semibold iv-cursor-pointer"]')
signup_button.click()
temp_driver = sb.get_new_driver(undetectable=True)
temp_email_gen_url = "https://temp-mail.org/en"
temp_driver.activate_cdp_mode(temp_email_gen_url)
temp_email = str(temp_driver.cdp.get_text("//input[@class='emailbox-input opentip']", timeout=300))
# <FAILS HERE> #
At the part that says FAILS HERE, the following error occurs:
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: cannot connect to chrome at 127.0.0.1:64237
from chrome not reachable
Does anybody know the reason for this error?
Beta Was this translation helpful? Give feedback.
All reactions
You spun up a new driver using sb.get_new_driver()
, which changed the default driver, however...
it looks like you didn't activate CDP Mode with the newer driver, so it doesn't have the CDP Mode methods.
Also looks like some import parts are missing (failure was on line 315, but you didn't show that many lines).
A minimal, self-contained code block to reproduce the issue would be more helpful in the future.
Replies: 1 comment 6 replies
-
You spun up a new driver using sb.get_new_driver()
, which changed the default driver, however...
it looks like you didn't activate CDP Mode with the newer driver, so it doesn't have the CDP Mode methods.
Also looks like some import parts are missing (failure was on line 315, but you didn't show that many lines).
A minimal, self-contained code block to reproduce the issue would be more helpful in the future.
Beta Was this translation helpful? Give feedback.
All reactions
-
That usually means Chrome is not in the default location for the OS being used, so you must set it manually with binary_location
. Eg: binary_location="/usr/bin/google-chrome"
. Figure out where Chrome is located, and then set it. Note that on Linux, you'll need to use either google-chrome-stable
or google-chrome
(but NOT chromium
).
Other possible reasons may include port conflicts if multithreading, or missing Linux permissions.
Beta Was this translation helpful? Give feedback.
All reactions
-
I am currently using Windows and I am not multithreading. I have tried setting binary_location
but I appear to receive the same error, are there any other common causes for this error?
Beta Was this translation helpful? Give feedback.
All reactions
-
The driver
itself wouldn't have activate_cdp_mode()
. It would have uc_activate_cdp_mode()
. sb
has activate_cdp_mode()
, so it should be failing earlier than it did. Maybe switch to the BaseCase
format and see the example for get_new_driver()
- examples/test_multiple_drivers.py, or stick to one driver within your with SB
block.
Beta Was this translation helpful? Give feedback.
All reactions
-
OK, I shall have a look at the BaseCase
format, will I still be able to use the CDP feature in this format?
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, you can use UC Mode / CDP Mode with BaseCase formats. Eg. https://github.com/seleniumbase/SeleniumBase/blob/master/examples/verify_undetected.py, but add self.activate_cdp_mode()
.
Beta Was this translation helpful? Give feedback.