seleniumbase / SeleniumBase

📊 Python's all-in-one framework for web crawling, scraping, testing, and reporting. Supports pytest. UC Mode provides stealth. Includes many tools.
https://seleniumbase.io
MIT License
5.32k stars 977 forks source link

UC mode dosent respond. #2206

Closed june9713 closed 1 year ago

june9713 commented 1 year ago

`from seleniumbase import SB

with SB(uc=True) as sb: sb.driver.get("https://nowsecure.nl/#relax") sb.sleep(2) if not sb.is_text_visible("OH YEAH, you passed!", "h1"): sb.get_new_driver(undetectable=True) sb.driver.get("https://nowsecure.nl/#relax") sb.sleep(2) if not sb.is_text_visible("OH YEAH, you passed!", "h1"): if sb.is_element_visible('iframe[src="challenge"]'): with sb.frame_switch('iframe[src="challenge"]'): sb.click("area") sb.sleep(4) sb.activate_demo_mode() sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)`

11 if sb.is_element_visible('iframe[src="challenge"]'): 12 with sb.frame_switch('iframe[src="challenge"]'): ---> 13 sb.click("area") 14 sb.sleep(4) 15 sb.activate_demo_mode()

File c:\Users\user\anaconda3\envs\pybase\lib\site-packages\seleniumbase\fixtures\base_case.py:399, in BaseCase.click(self, selector, by, timeout, delay, scroll) 397 if self.needs_minimum_wait() or self.browser == "safari": 398 time.sleep(0.03) --> 399 element = page_actions.wait_for_element_visible( 400 self.driver, 401 selector, 402 by, 403 timeout=timeout, 404 original_selector=original_selector, 405 ) 406 self.demo_mode_highlight_if_active(original_selector, original_by) 407 if scroll and not self.demo_mode and not self.slow_mode:

File c:\Users\user\anaconda3\envs\pybase\lib\site-packages\seleniumbase\fixtures\page_actions.py:508, in wait_for_element_visible(driver, selector, by, timeout, original_selector, ignore_test_time_limit) 501 if not is_present: 502 # The element does not exist in the HTML 503 message = "Element {%s} was not present after %s second%s!" % ( 504 selector, 505 timeout, 506 plural, 507 ) --> 508 timeout_exception(NoSuchElementException, message) 509 # The element exists in the HTML, but is not visible 510 message = "Element {%s} was not visible after %s second%s!" % ( 511 selector, 512 timeout, 513 plural, 514 )

File c:\Users\user\anaconda3\envs\pybase\lib\site-packages\seleniumbase\fixtures\page_actions.py:266, in timeout_exception(exception, message) 264 def timeout_exception(exception, message): 265 exc, msg = shared_utils.format_exc(exception, message) --> 266 raise exc(msg)

NoSuchElementException: Message: Element {area} was not present after 7 seconds!

Hello. If I set UC as True , Broser is opend but driver cant control browser , after 5 mininutes and it makes errors like above. if UC = False , It works well. Can anybody share expirience about this please?

mdmintz commented 1 year ago

Looks like you have an old version of the test. Use: SeleniumBase/examples/raw_uc_mode.py

from seleniumbase import SB

with SB(uc=True) as sb:
    sb.driver.get("https://nowsecure.nl/#relax")
    sb.sleep(1)
    if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
        sb.get_new_driver(undetectable=True)
        sb.driver.get("https://nowsecure.nl/#relax")
        sb.sleep(1)
    if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
        if sb.is_element_visible('iframe[src*="challenge"]'):
            with sb.frame_switch('iframe[src*="challenge"]'):
                sb.click("span.mark")
                sb.sleep(2)
    sb.activate_demo_mode()
    sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)

And you may be using an older version of SeleniumBase. Upgrade to the latest.

And learn to use Markdown so that you can format your code with proper indentations and make it readable: https://stackedit.io/