@@ -3969,8 +3969,23 @@ def set_content_to_parent_frame(self):
39693969
39703970 def open_new_window(self, switch_to=True):
39713971 """Opens a new browser tab/window and switches to it by default."""
3972+ url = None
3973+ if self.__looks_like_a_page_url(str(switch_to)):
3974+ # Different API for CDP Mode: First arg is a `url`.
3975+ # (Also, don't break backwards compat for reg mode)
3976+ url = switch_to
3977+ switch_to = True
39723978 if self.__is_cdp_swap_needed():
3973- self.cdp.open_new_tab(switch_to=switch_to)
3979+ self.cdp.open_new_tab(url=url, switch_to=switch_to)
3980+ return
3981+ elif (
3982+ hasattr(self.driver, "_is_using_uc")
3983+ and self.driver._is_using_uc
3984+ and hasattr(self.driver, "_is_using_cdp")
3985+ and self.driver._is_using_cdp
3986+ ):
3987+ self.disconnect()
3988+ self.cdp.open_new_tab(url=url, switch_to=switch_to)
39743989 return
39753990 self.wait_for_ready_state_complete()
39763991 if switch_to:
@@ -5040,9 +5055,8 @@ def activate_cdp_mode(self, url=None, **kwargs):
50405055 if hasattr(self.cdp, "find_element_by_text"):
50415056 self.find_element_by_text = self.cdp.find_element_by_text
50425057 if (
5043- hasattr(sb_config, "_cdp_proxy")
5044- and sb_config._cdp_proxy
5045- and "@" in sb_config._cdp_proxy
5058+ hasattr(self.driver, "_is_using_auth")
5059+ and self.driver._is_using_auth
50465060 ):
50475061 with suppress(Exception):
50485062 self.cdp.loop.run_until_complete(self.cdp.page.wait(0.25))
@@ -6364,6 +6378,7 @@ def press_up_arrow(self, selector="body", times=1, by="css selector"):
63646378 By default, "html" will be used as the CSS Selector target.
63656379 You can specify how many times in-a-row the action happens."""
63666380 self.__check_scope()
6381+ self._check_browser()
63676382 if times < 1:
63686383 return
63696384 element = self.wait_for_element_present(selector)
@@ -6386,6 +6401,7 @@ def press_down_arrow(self, selector="body", times=1, by="css selector"):
63866401 By default, "html" will be used as the CSS Selector target.
63876402 You can specify how many times in-a-row the action happens."""
63886403 self.__check_scope()
6404+ self._check_browser()
63896405 if times < 1:
63906406 return
63916407 element = self.wait_for_element_present(selector)
@@ -6408,6 +6424,7 @@ def press_left_arrow(self, selector="body", times=1, by="css selector"):
64086424 By default, "html" will be used as the CSS Selector target.
64096425 You can specify how many times in-a-row the action happens."""
64106426 self.__check_scope()
6427+ self._check_browser()
64116428 if times < 1:
64126429 return
64136430 element = self.wait_for_element_present(selector)
@@ -6430,6 +6447,7 @@ def press_right_arrow(self, selector="body", times=1, by="css selector"):
64306447 By default, "html" will be used as the CSS Selector target.
64316448 You can specify how many times in-a-row the action happens."""
64326449 self.__check_scope()
6450+ self._check_browser()
64336451 if times < 1:
64346452 return
64356453 element = self.wait_for_element_present(selector)
@@ -8781,6 +8799,9 @@ def set_text(self, selector, text, by="css selector", timeout=None):
87818799 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
87828800 timeout = self.__get_new_timeout(timeout)
87838801 selector, by = self.__recalculate_selector(selector, by)
8802+ if self.__is_cdp_swap_needed():
8803+ self.cdp.set_value(selector, text)
8804+ return
87848805 self.wait_for_ready_state_complete()
87858806 element = page_actions.wait_for_element_present(
87868807 self.driver, selector, by, timeout
@@ -8801,10 +8822,14 @@ def set_text_content(
88018822 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
88028823 timeout = self.__get_new_timeout(timeout)
88038824 selector, by = self.__recalculate_selector(selector, by)
8804- self.wait_for_ready_state_complete()
8805- element = page_actions.wait_for_element_present(
8806- self.driver, selector, by, timeout
8807- )
8825+ element = None
8826+ if self.__is_cdp_swap_needed():
8827+ element = self.cdp.select(selector, timeout=timeout)
8828+ else:
8829+ self.wait_for_ready_state_complete()
8830+ element = page_actions.wait_for_element_present(
8831+ self.driver, selector, by, timeout
8832+ )
88088833 if element.tag_name.lower() in ["input", "textarea"]:
88098834 self.js_update_text(selector, text, by=by, timeout=timeout)
88108835 return
0 commit comments