@@ -1884,6 +1884,8 @@ def get_attribute(
1884
1884
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
1885
1885
timeout = self.__get_new_timeout(timeout)
1886
1886
selector, by = self.__recalculate_selector(selector, by)
1887
+ if self.__is_cdp_swap_needed():
1888
+ return self.cdp.get_element_attribute(selector)
1887
1889
self.wait_for_ready_state_complete()
1888
1890
time.sleep(0.01)
1889
1891
if self.__is_shadow_selector(selector):
@@ -2460,16 +2462,14 @@ def is_checked(self, selector, by="css selector", timeout=None):
2460
2462
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
2461
2463
timeout = self.__get_new_timeout(timeout)
2462
2464
selector, by = self.__recalculate_selector(selector, by)
2465
+ if self.__is_cdp_swap_needed():
2466
+ return self.cdp.is_checked(selector)
2463
2467
kind = self.get_attribute(selector, "type", by=by, timeout=timeout)
2464
2468
if kind != "checkbox" and kind != "radio":
2465
2469
raise Exception("Expecting a checkbox or a radio button element!")
2466
- is_checked = self.get_attribute(
2470
+ return self.get_attribute(
2467
2471
selector, "checked", by=by, timeout=timeout, hard_fail=False
2468
2472
)
2469
- if is_checked:
2470
- return True
2471
- else: # (NoneType)
2472
- return False
2473
2473
2474
2474
def is_selected(self, selector, by="css selector", timeout=None):
2475
2475
"""Same as is_checked()"""
@@ -2479,6 +2479,9 @@ def check_if_unchecked(self, selector, by="css selector"):
2479
2479
"""If a checkbox or radio button is not checked, will check it."""
2480
2480
self.__check_scope()
2481
2481
selector, by = self.__recalculate_selector(selector, by)
2482
+ if self.__is_cdp_swap_needed():
2483
+ self.cdp.check_if_unchecked(selector)
2484
+ return
2482
2485
if not self.is_checked(selector, by=by):
2483
2486
if self.is_element_visible(selector, by=by):
2484
2487
self.click(selector, by=by)
@@ -2515,6 +2518,9 @@ def uncheck_if_checked(self, selector, by="css selector"):
2515
2518
"""If a checkbox is checked, will uncheck it."""
2516
2519
self.__check_scope()
2517
2520
selector, by = self.__recalculate_selector(selector, by)
2521
+ if self.__is_cdp_swap_needed():
2522
+ self.cdp.uncheck_if_checked(selector)
2523
+ return
2518
2524
if self.is_checked(selector, by=by):
2519
2525
if self.is_element_visible(selector, by=by):
2520
2526
self.click(selector, by=by)
@@ -6087,6 +6093,9 @@ def scroll_to(self, selector, by="css selector", timeout=None):
6087
6093
timeout = settings.SMALL_TIMEOUT
6088
6094
if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
6089
6095
timeout = self.__get_new_timeout(timeout)
6096
+ if self.__is_cdp_swap_needed():
6097
+ self.cdp.scroll_into_view(selector)
6098
+ return
6090
6099
if self.demo_mode or self.slow_mode:
6091
6100
self.slow_scroll_to(selector, by=by, timeout=timeout)
6092
6101
return
0 commit comments