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

Method assert_attribute

seleniumbase/fixtures/base_case.py:8517–8573  ·  view source on GitHub ↗

Raises an exception if the element attribute/value is not found. If the value is not specified, the attribute only needs to exist. Returns True if successful. Default timeout = SMALL_TIMEOUT.

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

Source from the content-addressed store, hash-verified

8515 )
8516
8517 def assert_attribute(
8518 self, selector, attribute, value=None, by="css selector", timeout=None
8519 ):
8520 """Raises an exception if the element attribute/value is not found.
8521 If the value is not specified, the attribute only needs to exist.
8522 Returns True if successful. Default timeout = SMALL_TIMEOUT."""
8523 self.__check_scope()
8524 if not timeout:
8525 timeout = settings.SMALL_TIMEOUT
8526 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
8527 timeout = self.__get_new_timeout(timeout)
8528 selector, by = self.__recalculate_selector(selector, by)
8529 if self.__is_cdp_swap_needed():
8530 self.cdp.assert_element_attribute(selector, attribute, value)
8531 return
8532 self.wait_for_attribute(
8533 selector, attribute, value=value, by=by, timeout=timeout
8534 )
8535 if (
8536 self.demo_mode
8537 and not self.__is_shadow_selector(selector)
8538 and self.is_element_visible(selector, by=by)
8539 ):
8540 a_a = "ASSERT ATTRIBUTE"
8541 i_n = "in"
8542 if self._language != "English":
8543 from seleniumbase.fixtures.words import SD
8544
8545 a_a = SD.translate_assert_attribute(self._language)
8546 i_n = SD.translate_in(self._language)
8547 if not value:
8548 messenger_post = "<b>%s</b>: [%s] %s %s: %s" % (
8549 a_a,
8550 attribute,
8551 i_n,
8552 by.upper(),
8553 selector,
8554 )
8555 else:
8556 messenger_post = '<b>%s</b>: [%s="%s"] %s %s: %s' % (
8557 a_a,
8558 attribute,
8559 value,
8560 i_n,
8561 by.upper(),
8562 selector,
8563 )
8564 self.__highlight_with_assert_success(messenger_post, selector, by)
8565 if self.recorder_mode and self.__current_url_is_recordable():
8566 if self.get_session_storage_item("pause_recorder") == "no":
8567 time_stamp = self.execute_script("return Date.now();")
8568 origin = self.get_origin()
8569 value = value.replace("\\", "\\\\")
8570 sel_att_val = [selector, attribute, value]
8571 action = ["as_at", sel_att_val, origin, time_stamp]
8572 self.__extra_actions.append(action)
8573 return True
8574

Callers 14

assert_attributeFunction · 0.80
controleren_attribuutMethod · 0.80
vérifier_attributMethod · 0.80
verificare_attributoMethod · 0.80
verificar_atributoMethod · 0.80
특성_확인Method · 0.80
属性を確認するMethod · 0.80
断言属性Method · 0.80
verificar_atributoMethod · 0.80

Calls 15

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
wait_for_attributeMethod · 0.95
__is_shadow_selectorMethod · 0.95
is_element_visibleMethod · 0.95
execute_scriptMethod · 0.95
get_originMethod · 0.95

Tested by 3

test_baseMethod · 0.64