MCPcopy Create free account
hub / github.com/seleniumbase/SeleniumBase / assert_text

Method assert_text

seleniumbase/fixtures/base_case.py:10817–10901  ·  view source on GitHub ↗

Similar to wait_for_text_visible() Raises an exception if the element or the text is not found. The text only needs to be a subset within the complete text. The text can be a string or a list/tuple of text substrings. Returns True if successful. Default timeout = SMAL

(
        self, text, selector="body", by="css selector", timeout=None
    )

Source from the content-addressed store, hash-verified

10815 return self.assert_text(text, selector, by=by, timeout=timeout)
10816
10817 def assert_text(
10818 self, text, selector="body", by="css selector", timeout=None
10819 ):
10820 """Similar to wait_for_text_visible()
10821 Raises an exception if the element or the text is not found.
10822 The text only needs to be a subset within the complete text.
10823 The text can be a string or a list/tuple of text substrings.
10824 Returns True if successful. Default timeout = SMALL_TIMEOUT."""
10825 self.__check_scope()
10826 if not timeout:
10827 timeout = settings.SMALL_TIMEOUT
10828 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
10829 timeout = self.__get_new_timeout(timeout)
10830 original_selector = selector
10831 selector, by = self.__recalculate_selector(selector, by)
10832 if isinstance(text, (list, tuple)):
10833 text_list = text
10834 for _text in text_list:
10835 self.wait_for_text_visible(
10836 _text, selector, by=by, timeout=timeout
10837 )
10838 if self.demo_mode:
10839 a_t = "ASSERT TEXT"
10840 i_n = "in"
10841 if self._language != "English":
10842 from seleniumbase.fixtures.words import SD
10843
10844 a_t = SD.translate_assert_text(self._language)
10845 i_n = SD.translate_in(self._language)
10846 messenger_post = "<b>%s</b>: {%s} %s %s: %s" % (
10847 a_t, _text, i_n, by.upper(), selector
10848 )
10849 self.__highlight_with_assert_success(
10850 messenger_post, selector, by
10851 )
10852 elif self.__is_cdp_swap_needed():
10853 if self.demo_mode:
10854 a_t = "ASSERT TEXT"
10855 i_n = "in"
10856 if self._language != "English":
10857 from seleniumbase.fixtures.words import SD
10858
10859 a_t = SD.translate_assert_text(self._language)
10860 i_n = SD.translate_in(self._language)
10861 messenger_post = "<b>%s</b>: {%s} %s %s: %s" % (
10862 a_t, text, i_n, by.upper(), selector
10863 )
10864 self.__highlight_with_assert_success(
10865 messenger_post, selector, by
10866 )
10867 self.cdp.assert_text(text, selector, timeout=timeout)
10868 return True
10869 elif self.__is_shadow_selector(selector):
10870 if hasattr(self, "connect") and not self.is_connected():
10871 self.connect()
10872 self.__assert_shadow_text_visible(text, selector, timeout)
10873 return True
10874 else:

Callers 2

assert_text_visibleMethod · 0.95
assert_textFunction · 0.45

Calls 15

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
wait_for_text_visibleMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
__is_shadow_selectorMethod · 0.95
is_connectedMethod · 0.95
execute_scriptMethod · 0.95

Tested by

no test coverage detected