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

Method hide_elements

seleniumbase/fixtures/base_case.py:7332–7353  ·  view source on GitHub ↗

Hide all elements on the page that match the selector.

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

Source from the content-addressed store, hash-verified

7330 self.execute_script(script)
7331
7332 def hide_elements(self, selector, by="css selector"):
7333 """Hide all elements on the page that match the selector."""
7334 self.__check_scope()
7335 with suppress(Exception):
7336 self.wait_for_element_visible("body", timeout=1.5)
7337 selector, by = self.__recalculate_selector(selector, by)
7338 css_selector = self.convert_to_css_selector(selector, by=by)
7339 if ":contains(" in css_selector:
7340 script = """jQuery('%s').hide();""" % css_selector
7341 self.safe_execute_script(script)
7342 else:
7343 css_selector = re.escape(css_selector) # Add "\\" to special chars
7344 css_selector = self.__escape_quotes_if_needed(css_selector)
7345 script = (
7346 """var $elements = document.querySelectorAll('%s');
7347 var index = 0, length = $elements.length;
7348 for(; index < length; index++){
7349 $elements[index].style.display="none";
7350 $elements[index].style.visibility="hidden";}"""
7351 % css_selector
7352 )
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."""

Callers 8

test_hack_searchMethod · 0.80
test_google_tourMethod · 0.80
test_google_tourMethod · 0.80
test_google_tourMethod · 0.80
test_google_tourMethod · 0.80
test_google_tourMethod · 0.80
hide_sign_in_pop_upMethod · 0.80

Calls 7

__check_scopeMethod · 0.95
safe_execute_scriptMethod · 0.95
execute_scriptMethod · 0.95

Tested by 8

test_hack_searchMethod · 0.64
test_google_tourMethod · 0.64
test_google_tourMethod · 0.64
test_google_tourMethod · 0.64
test_google_tourMethod · 0.64
test_google_tourMethod · 0.64
hide_sign_in_pop_upMethod · 0.64