@@ -834,22 +834,30 @@ def open_if_not_url(self, url):
834834 def is_element_present(self, selector, by=By.CSS_SELECTOR):
835835 self.wait_for_ready_state_complete()
836836 selector, by = self.__recalculate_selector(selector, by)
837+ if self.__is_shadow_selector(selector):
838+ return self.__is_shadow_element_present(selector)
837839 return page_actions.is_element_present(self.driver, selector, by)
838840
839841 def is_element_visible(self, selector, by=By.CSS_SELECTOR):
840842 self.wait_for_ready_state_complete()
841843 selector, by = self.__recalculate_selector(selector, by)
844+ if self.__is_shadow_selector(selector):
845+ return self.__is_shadow_element_visible(selector)
842846 return page_actions.is_element_visible(self.driver, selector, by)
843847
844848 def is_element_enabled(self, selector, by=By.CSS_SELECTOR):
845849 self.wait_for_ready_state_complete()
846850 selector, by = self.__recalculate_selector(selector, by)
851+ if self.__is_shadow_selector(selector):
852+ return self.__is_shadow_element_enabled(selector)
847853 return page_actions.is_element_enabled(self.driver, selector, by)
848854
849855 def is_text_visible(self, text, selector="html", by=By.CSS_SELECTOR):
850856 self.wait_for_ready_state_complete()
851857 time.sleep(0.01)
852858 selector, by = self.__recalculate_selector(selector, by)
859+ if self.__is_shadow_selector(selector):
860+ return self.__is_shadow_text_visible(text, selector)
853861 return page_actions.is_text_visible(self.driver, text, selector, by)
854862
855863 def is_attribute_present(
@@ -860,6 +868,10 @@ def is_attribute_present(
860868 self.wait_for_ready_state_complete()
861869 time.sleep(0.01)
862870 selector, by = self.__recalculate_selector(selector, by)
871+ if self.__is_shadow_selector(selector):
872+ return self.__is_shadow_attribute_present(
873+ selector, attribute, value
874+ )
863875 return page_actions.is_attribute_present(
864876 self.driver, selector, attribute, value, by
865877 )
@@ -1259,6 +1271,8 @@ def get_attribute(
12591271 selector, by = self.__recalculate_selector(selector, by)
12601272 self.wait_for_ready_state_complete()
12611273 time.sleep(0.01)
1274+ if self.__is_shadow_selector(selector):
1275+ return self.__get_shadow_attribute(selector, attribute)
12621276 element = page_actions.wait_for_element_present(
12631277 self.driver, selector, by, timeout
12641278 )
@@ -5834,7 +5848,7 @@ def skip(self, reason=""):
58345848 self.__passed_then_skipped = True
58355849 self.__will_be_skipped = True
58365850 sb_config._results[test_id] = "Skipped"
5837- if self.with_db_reporting:
5851+ if hasattr(self, "with_db_reporting") and self.with_db_reporting:
58385852 if self.is_pytest:
58395853 self.__skip_reason = reason
58405854 else:
@@ -6004,6 +6018,10 @@ def __get_shadow_text(self, selector):
60046018 element = self.__get_shadow_element(selector)
60056019 return element.text
60066020
6021+ def __get_shadow_attribute(self, selector, attribute):
6022+ element = self.__get_shadow_element(selector)
6023+ return element.get_attribute(attribute)
6024+
60076025 def __wait_for_shadow_text_visible(self, text, selector):
60086026 start_ms = time.time() * 1000.0
60096027 stop_ms = start_ms + (settings.SMALL_TIMEOUT * 1000.0)
@@ -6132,6 +6150,36 @@ def __is_shadow_element_visible(self, selector):
61326150 except Exception:
61336151 return False
61346152
6153+ def __is_shadow_element_enabled(self, selector):
6154+ try:
6155+ element = self.__get_shadow_element(selector, timeout=0.1)
6156+ return element.is_enabled()
6157+ except Exception:
6158+ return False
6159+
6160+ def __is_shadow_text_visible(self, text, selector):
6161+ try:
6162+ element = self.__get_shadow_element(selector, timeout=0.1)
6163+ return element.is_displayed() and text in element.text
6164+ except Exception:
6165+ return False
6166+
6167+ def __is_shadow_attribute_present(self, selector, attribute, value=None):
6168+ try:
6169+ element = self.__get_shadow_element(selector, timeout=0.1)
6170+ found_value = element.get_attribute(attribute)
6171+ if found_value is None:
6172+ return False
6173+ if value is not None:
6174+ if found_value == value:
6175+ return True
6176+ else:
6177+ return False
6178+ else:
6179+ return True
6180+ except Exception:
6181+ return False
6182+
61356183 def __wait_for_shadow_element_present(self, selector):
61366184 element = self.__get_shadow_element(selector)
61376185 return element
0 commit comments