@@ -1884,6 +1884,8 @@ def get_attribute(
18841884 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
18851885 timeout = self.__get_new_timeout(timeout)
18861886 selector, by = self.__recalculate_selector(selector, by)
1887+ if self.__is_cdp_swap_needed():
1888+ return self.cdp.get_element_attribute(selector)
18871889 self.wait_for_ready_state_complete()
18881890 time.sleep(0.01)
18891891 if self.__is_shadow_selector(selector):
@@ -2460,16 +2462,14 @@ def is_checked(self, selector, by="css selector", timeout=None):
24602462 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
24612463 timeout = self.__get_new_timeout(timeout)
24622464 selector, by = self.__recalculate_selector(selector, by)
2465+ if self.__is_cdp_swap_needed():
2466+ return self.cdp.is_checked(selector)
24632467 kind = self.get_attribute(selector, "type", by=by, timeout=timeout)
24642468 if kind != "checkbox" and kind != "radio":
24652469 raise Exception("Expecting a checkbox or a radio button element!")
2466- is_checked = self.get_attribute(
2470+ return self.get_attribute(
24672471 selector, "checked", by=by, timeout=timeout, hard_fail=False
24682472 )
2469- if is_checked:
2470- return True
2471- else: # (NoneType)
2472- return False
24732473
24742474 def is_selected(self, selector, by="css selector", timeout=None):
24752475 """Same as is_checked()"""
@@ -2479,6 +2479,9 @@ def check_if_unchecked(self, selector, by="css selector"):
24792479 """If a checkbox or radio button is not checked, will check it."""
24802480 self.__check_scope()
24812481 selector, by = self.__recalculate_selector(selector, by)
2482+ if self.__is_cdp_swap_needed():
2483+ self.cdp.check_if_unchecked(selector)
2484+ return
24822485 if not self.is_checked(selector, by=by):
24832486 if self.is_element_visible(selector, by=by):
24842487 self.click(selector, by=by)
@@ -2515,6 +2518,9 @@ def uncheck_if_checked(self, selector, by="css selector"):
25152518 """If a checkbox is checked, will uncheck it."""
25162519 self.__check_scope()
25172520 selector, by = self.__recalculate_selector(selector, by)
2521+ if self.__is_cdp_swap_needed():
2522+ self.cdp.uncheck_if_checked(selector)
2523+ return
25182524 if self.is_checked(selector, by=by):
25192525 if self.is_element_visible(selector, by=by):
25202526 self.click(selector, by=by)
@@ -6087,6 +6093,9 @@ def scroll_to(self, selector, by="css selector", timeout=None):
60876093 timeout = settings.SMALL_TIMEOUT
60886094 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
60896095 timeout = self.__get_new_timeout(timeout)
6096+ if self.__is_cdp_swap_needed():
6097+ self.cdp.scroll_into_view(selector)
6098+ return
60906099 if self.demo_mode or self.slow_mode:
60916100 self.slow_scroll_to(selector, by=by, timeout=timeout)
60926101 return
0 commit comments