MCPcopy Index your code
hub / github.com/seleniumbase/SeleniumBase / is_checked

Method is_checked

seleniumbase/fixtures/base_case.py:2545–2566  ·  view source on GitHub ↗

Determines if a checkbox or a radio button element is checked. Returns True if the element is checked. Returns False if the element is not checked. If the element is not present on the page, raises an exception. If the element is not a checkbox or radio, raises an exc

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

Source from the content-addressed store, hash-verified

2543 )
2544
2545 def is_checked(self, selector, by="css selector", timeout=None):
2546 """Determines if a checkbox or a radio button element is checked.
2547 Returns True if the element is checked.
2548 Returns False if the element is not checked.
2549 If the element is not present on the page, raises an exception.
2550 If the element is not a checkbox or radio, raises an exception."""
2551 self.__check_scope()
2552 if not timeout:
2553 timeout = settings.SMALL_TIMEOUT
2554 if self.timeout_multiplier and timeout == settings.SMALL_TIMEOUT:
2555 timeout = self.__get_new_timeout(timeout)
2556 selector, by = self.__recalculate_selector(selector, by)
2557 if self.__is_cdp_swap_needed():
2558 return self.cdp.is_checked(selector)
2559 kind = self.get_attribute(selector, "type", by=by, timeout=timeout)
2560 if kind != "checkbox" and kind != "radio":
2561 raise Exception("Expecting a checkbox or a radio button element!")
2562 return bool(
2563 self.get_attribute(
2564 selector, "checked", by=by, timeout=timeout, hard_fail=False
2565 )
2566 )
2567
2568 def is_selected(self, selector, by="css selector", timeout=None):
2569 """Same as is_checked()"""

Callers 3

is_selectedMethod · 0.95
check_if_uncheckedMethod · 0.95
uncheck_if_checkedMethod · 0.95

Calls 5

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
get_attributeMethod · 0.95

Tested by

no test coverage detected