Remove all elements on the page that match the selector.
(self, selector)
| 1069 | self.select(selector).remove_from_dom() |
| 1070 | |
| 1071 | def remove_elements(self, selector): |
| 1072 | """Remove all elements on the page that match the selector.""" |
| 1073 | css_selector = self.__convert_to_css_if_xpath(selector) |
| 1074 | css_selector = re.escape(css_selector) # Add "\\" to special chars |
| 1075 | css_selector = js_utils.escape_quotes_if_needed(css_selector) |
| 1076 | js_code = ( |
| 1077 | """var $elements = document.querySelectorAll('%s'); |
| 1078 | var index = 0, length = $elements.length; |
| 1079 | for(; index < length; index++){ |
| 1080 | $elements[index].remove();}""" |
| 1081 | % css_selector |
| 1082 | ) |
| 1083 | with suppress(Exception): |
| 1084 | self.loop.run_until_complete(self.page.evaluate(js_code)) |
| 1085 | |
| 1086 | def send_keys(self, selector, text, timeout=None): |
| 1087 | if not timeout: |