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

Method assert_element_visible

seleniumbase/core/sb_cdp.py:3212–3233  ·  view source on GitHub ↗

Same as assert_element()

(self, selector, timeout=None)

Source from the content-addressed store, hash-verified

3210 return True
3211
3212 def assert_element_visible(self, selector, timeout=None):
3213 """Same as assert_element()"""
3214 if not timeout:
3215 timeout = settings.SMALL_TIMEOUT
3216 failure = False
3217 message = ""
3218 try:
3219 self.select(selector, timeout=timeout)
3220 except Exception:
3221 failure = True
3222 plural = "s"
3223 if timeout == 1:
3224 plural = ""
3225 msg = "\n Element {%s} was not found after %s second%s!"
3226 message = msg % (selector, timeout, plural)
3227 if failure:
3228 raise Exception(message)
3229 for i in range(30):
3230 if self.is_element_visible(selector):
3231 return True
3232 time.sleep(0.1)
3233 raise Exception("Element {%s} was not visible!" % selector)
3234
3235 def assert_element_present(self, selector, timeout=None):
3236 """Assert element is present in the DOM. (Visibility NOT required)"""

Calls 3

selectMethod · 0.95
is_element_visibleMethod · 0.95
sleepMethod · 0.45

Tested by

no test coverage detected