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

Method assert_element

seleniumbase/fixtures/base_case.py:10534–10588  ·  view source on GitHub ↗

Similar to wait_for_element_visible(), but returns nothing. As above, raises an exception if nothing can be found. Returns True if successful. Default timeout = SMALL_TIMEOUT.

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

Source from the content-addressed store, hash-verified

10532 return self.wait_for_element_visible(selector, by=by, timeout=timeout)
10533
10534 def assert_element(self, selector, by="css selector", timeout=None):
10535 """Similar to wait_for_element_visible(), but returns nothing.
10536 As above, raises an exception if nothing can be found.
10537 Returns True if successful. Default timeout = SMALL_TIMEOUT."""
10538 self.__check_scope()
10539 if not timeout:
10540 timeout = settings.SMALL_TIMEOUT
10541 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
10542 timeout = self.__get_new_timeout(timeout)
10543 if self.__is_cdp_swap_needed():
10544 if self.demo_mode:
10545 selector, by = self.__recalculate_selector(
10546 selector, by, xp_ok=False
10547 )
10548 a_t = "ASSERT"
10549 if self._language != "English":
10550 from seleniumbase.fixtures.words import SD
10551
10552 a_t = SD.translate_assert(self._language)
10553 messenger_post = "<b>%s %s</b>: %s" % (
10554 a_t, by.upper(), selector
10555 )
10556 self.__highlight_with_assert_success(
10557 messenger_post, selector, by
10558 )
10559 self.cdp.assert_element(selector, timeout=timeout)
10560 return True
10561 if isinstance(selector, list):
10562 self.assert_elements(selector, by=by, timeout=timeout)
10563 return True
10564 if self.__is_shadow_selector(selector):
10565 self.__assert_shadow_element_visible(selector)
10566 return True
10567 self.wait_for_element_visible(selector, by=by, timeout=timeout)
10568 original_selector = selector
10569 if self.demo_mode:
10570 selector, by = self.__recalculate_selector(
10571 selector, by, xp_ok=False
10572 )
10573 a_t = "ASSERT"
10574 if self._language != "English":
10575 from seleniumbase.fixtures.words import SD
10576
10577 a_t = SD.translate_assert(self._language)
10578 messenger_post = "<b>%s %s</b>: %s" % (a_t, by.upper(), selector)
10579 self.__highlight_with_assert_success(messenger_post, selector, by)
10580 if self.recorder_mode and self.__current_url_is_recordable():
10581 if self.get_session_storage_item("pause_recorder") == "no":
10582 if by == By.XPATH:
10583 selector = original_selector
10584 time_stamp = self.execute_script("return Date.now();")
10585 origin = self.get_origin()
10586 action = ["as_el", selector, origin, time_stamp]
10587 self.__extra_actions.append(action)
10588 return True
10589
10590 def assert_element_visible(
10591 self, selector, by="css selector", timeout=None

Callers 2

assert_element_visibleFunction · 0.45

Calls 14

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
assert_elementsMethod · 0.95
__is_shadow_selectorMethod · 0.95
execute_scriptMethod · 0.95

Tested by

no test coverage detected