Show the first element on the page that matches the selector.
(self, selector, by="css selector")
| 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.""" |
nothing calls this directly
no test coverage detected