Browser Steps - Added new "Remove elements" action

pull/3012/head
dgtlmoon 2025-02-26 22:37:06 +01:00
rodzic 5e7c0880c1
commit 7903b03a0c
1 zmienionych plików z 5 dodań i 0 usunięć

Wyświetl plik

@ -38,6 +38,7 @@ browser_step_ui_config = {'Choose one': '0 0',
'Wait for seconds': '0 1',
'Wait for text': '0 1',
'Wait for text in element': '1 1',
'Remove elements': '1 0',
# 'Press Page Down': '0 0',
# 'Press Page Up': '0 0',
# weird bug, come back to it later
@ -192,6 +193,10 @@ class steppable_browser_interface():
def action_uncheck_checkbox(self, selector, value):
self.page.locator(selector).uncheck(timeout=self.action_timeout)
def action_remove_elements(self, selector, value):
"""Removes all elements matching the given selector from the DOM."""
self.page.locator(selector).evaluate_all("els => els.forEach(el => el.remove())")
# Responsible for maintaining a live 'context' with the chrome CDP
# @todo - how long do contexts live for anyway?