Merge pull request #3564 from seleniumbase/cdp-mode-patch-37
CDP Mode: Patch 37
This commit is contained in:
commit
5d732a412f
|
@ -144,7 +144,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
|
|||
sb.sleep(0.5)
|
||||
sb.scroll_into_view("a#advSearch")
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.mouse_click("a#advSearch")
|
||||
sb.cdp.click("a#advSearch")
|
||||
sb.sleep(1.2)
|
||||
sb.cdp.click('img[src*="img/pokedex/detail/025.png"]')
|
||||
sb.cdp.assert_text("Pikachu", 'div[class*="title"]')
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
"""Using CDP Mode with PyAutoGUI to bypass CAPTCHAs."""
|
||||
from seleniumbase import SB
|
||||
|
||||
with SB(uc=True, test=True, locale_code="en", incognito=True) as sb:
|
||||
with SB(uc=True, test=True, locale_code="en", guest=True) as sb:
|
||||
url = "https://www.cloudflare.com/login"
|
||||
sb.activate_cdp_mode(url)
|
||||
sb.sleep(3)
|
||||
sb.uc_gui_handle_captcha() # PyAutoGUI press Tab and Spacebar
|
||||
sb.sleep(2)
|
||||
|
||||
with SB(uc=True, test=True, locale_code="en", incognito=True) as sb:
|
||||
with SB(uc=True, test=True, locale_code="en", guest=True) as sb:
|
||||
url = "https://www.cloudflare.com/login"
|
||||
sb.activate_cdp_mode(url)
|
||||
sb.sleep(2)
|
||||
sb.sleep(3)
|
||||
sb.uc_gui_click_captcha() # PyAutoGUI click. (Linux needs it)
|
||||
sb.sleep(2)
|
||||
|
|
|
@ -14,7 +14,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
|
|||
sb.sleep(0.5)
|
||||
sb.scroll_into_view("a#advSearch")
|
||||
sb.sleep(0.5)
|
||||
sb.cdp.mouse_click("a#advSearch")
|
||||
sb.cdp.click("a#advSearch")
|
||||
sb.sleep(1.2)
|
||||
sb.cdp.click('img[src*="img/pokedex/detail/025.png"]')
|
||||
sb.cdp.assert_text("Pikachu", 'div[class*="title"]')
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
# seleniumbase package
|
||||
__version__ = "4.35.0"
|
||||
__version__ = "4.35.1"
|
||||
|
|
|
@ -288,7 +288,7 @@ class CDPMethods():
|
|||
return updated_elements
|
||||
|
||||
def select(self, selector, timeout=None):
|
||||
"""Similar to find_element(), but without text-based search."""
|
||||
"""Similar to find_element()."""
|
||||
if not timeout:
|
||||
timeout = settings.SMALL_TIMEOUT
|
||||
self.__add_light_pause()
|
||||
|
@ -297,12 +297,25 @@ class CDPMethods():
|
|||
tag_name = selector.split(":contains(")[0].split(" ")[-1]
|
||||
text = selector.split(":contains(")[1].split(")")[0][1:-1]
|
||||
with suppress(Exception):
|
||||
new_timeout = timeout
|
||||
if new_timeout < 1:
|
||||
new_timeout = 1
|
||||
self.loop.run_until_complete(
|
||||
self.page.select(tag_name, timeout=5)
|
||||
self.page.select(tag_name, timeout=new_timeout)
|
||||
)
|
||||
self.loop.run_until_complete(self.page.find(text, timeout=5))
|
||||
element = self.find_elements_by_text(text, tag_name=tag_name)[0]
|
||||
return self.__add_sync_methods(element)
|
||||
self.loop.run_until_complete(
|
||||
self.page.find(text, timeout=new_timeout)
|
||||
)
|
||||
elements = self.find_elements_by_text(text, tag_name=tag_name)
|
||||
if not elements:
|
||||
plural = "s"
|
||||
if timeout == 1:
|
||||
plural = ""
|
||||
msg = "\n Element {%s} was not found after %s second%s!"
|
||||
message = msg % (selector, timeout, plural)
|
||||
raise Exception(message)
|
||||
element = self.__add_sync_methods(elements[0])
|
||||
return element
|
||||
failure = False
|
||||
try:
|
||||
element = self.loop.run_until_complete(
|
||||
|
@ -313,11 +326,8 @@ class CDPMethods():
|
|||
plural = "s"
|
||||
if timeout == 1:
|
||||
plural = ""
|
||||
message = "\n Element {%s} was not found after %s second%s!" % (
|
||||
selector,
|
||||
timeout,
|
||||
plural,
|
||||
)
|
||||
msg = "\n Element {%s} was not found after %s second%s!"
|
||||
message = msg % (selector, timeout, plural)
|
||||
if failure:
|
||||
raise Exception(message)
|
||||
element = self.__add_sync_methods(element)
|
||||
|
|
|
@ -950,6 +950,8 @@ def post_message(driver, message, msg_dur=None, style="info"):
|
|||
set_messenger_theme(driver)
|
||||
try:
|
||||
execute_script(driver, messenger_script)
|
||||
except TypeError:
|
||||
pass
|
||||
except Exception:
|
||||
time.sleep(0.17)
|
||||
activate_messenger(driver)
|
||||
|
|
|
@ -2496,6 +2496,9 @@ def pytest_unconfigure(config):
|
|||
"""This runs after all tests have completed with pytest."""
|
||||
if "--co" in sys_argv or "--collect-only" in sys_argv:
|
||||
return
|
||||
reporter = config.pluginmanager.get_plugin("terminalreporter")
|
||||
if not hasattr(reporter, "_sessionstarttime"):
|
||||
return
|
||||
if hasattr(sb_config, "_multithreaded") and sb_config._multithreaded:
|
||||
import fasteners
|
||||
|
||||
|
|
Loading…
Reference in New Issue