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

Method wait_for_element

seleniumbase/fixtures/base_case.py:10378–10402  ·  view source on GitHub ↗

Waits for an element to appear in the HTML of a page. The element must be visible (it cannot be hidden).

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

Source from the content-addressed store, hash-verified

10376 )
10377
10378 def wait_for_element(self, selector, by="css selector", timeout=None):
10379 """Waits for an element to appear in the HTML of a page.
10380 The element must be visible (it cannot be hidden)."""
10381 self.__check_scope()
10382 if not timeout:
10383 timeout = settings.LARGE_TIMEOUT
10384 if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
10385 timeout = self.__get_new_timeout(timeout)
10386 original_selector = selector
10387 selector, by = self.__recalculate_selector(selector, by)
10388 if self.__is_cdp_swap_needed():
10389 return self.cdp.select(selector, timeout=timeout)
10390 if self.recorder_mode and self.__current_url_is_recordable():
10391 if self.get_session_storage_item("pause_recorder") == "no":
10392 if by == By.XPATH:
10393 selector = original_selector
10394 time_stamp = self.execute_script("return Date.now();")
10395 origin = self.get_origin()
10396 action = ["wf_el", selector, origin, time_stamp]
10397 self.__extra_actions.append(action)
10398 if self.__is_shadow_selector(selector):
10399 return self.__get_shadow_element(selector, timeout)
10400 return page_actions.wait_for_element_visible(
10401 self.driver, selector, by, timeout
10402 )
10403
10404 def select(self, selector, by="css selector", timeout=None):
10405 """Returns the element once it appears in the HTML.

Callers 1

get_select_optionsMethod · 0.95

Calls 12

__check_scopeMethod · 0.95
__get_new_timeoutMethod · 0.95
__is_cdp_swap_neededMethod · 0.95
execute_scriptMethod · 0.95
get_originMethod · 0.95
__is_shadow_selectorMethod · 0.95
__get_shadow_elementMethod · 0.95
selectMethod · 0.45

Tested by

no test coverage detected