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

Method show_element

seleniumbase/fixtures/base_case.py:7355–7382  ·  view source on GitHub ↗

Show the first element on the page that matches the selector.

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

Source from the content-addressed store, hash-verified

7353 self.execute_script(script)
7354
7355 def show_element(self, selector, by="css selector"):
7356 """Show the first element on the page that matches the selector."""
7357 self.__check_scope()
7358 element = None
7359 with suppress(Exception):
7360 self.wait_for_element_visible("body", timeout=1.5)
7361 element = self.wait_for_element_present(selector, by=by, timeout=1)
7362 selector, by = self.__recalculate_selector(selector, by)
7363 css_selector = self.convert_to_css_selector(selector, by=by)
7364 if ":contains(" in css_selector and element:
7365 script = (
7366 'const e = arguments[0];'
7367 'e.style.display="";e.style.visibility="visible";'
7368 )
7369 self.execute_script(script, element)
7370 elif ":contains(" in css_selector and not element:
7371 selector = self.__make_css_match_first_element_only(css_selector)
7372 script = """jQuery('%s').show(0);""" % selector
7373 self.safe_execute_script(script)
7374 else:
7375 css_selector = re.escape(css_selector) # Add "\\" to special chars
7376 css_selector = self.__escape_quotes_if_needed(css_selector)
7377 script = (
7378 'const e = document.querySelector("%s");'
7379 'e.style.display="";e.style.visibility="visible";'
7380 % css_selector
7381 )
7382 self.execute_script(script)
7383
7384 def show_elements(self, selector, by="css selector"):
7385 """Show all elements on the page that match the selector."""

Callers

nothing calls this directly

Calls 9

__check_scopeMethod · 0.95
execute_scriptMethod · 0.95
safe_execute_scriptMethod · 0.95

Tested by

no test coverage detected