-
-
Notifications
You must be signed in to change notification settings - Fork 25
Open
Description
Hi,
I ran in a case where I need to delete the text of an input before writing into it, and deleting the innerHTML would just mess with the rest of the scripts. So I've made a function for CTRL+A+Delete. I thought it is a common case and that people here could use this code.
from botasaurus_driver import cdp
def send_ctrl_a_delete(element):
element._tab.send(cdp.input_.dispatch_key_event(
type_="keyDown",
modifiers=2, # Ctrl = 2
code="KeyA",
key="a",
windows_virtual_key_code=65
))
element._tab.send(cdp.input_.dispatch_key_event(
type_="keyUp",
modifiers=2,
code="KeyA",
key="a",
windows_virtual_key_code=65
))
element._tab.send(cdp.input_.dispatch_key_event(
type_="keyDown",
code="Delete",
key="Delete",
windows_virtual_key_code=46
))
element._tab.send(cdp.input_.dispatch_key_event(
type_="keyUp",
code="Delete",
key="Delete",
windows_virtual_key_code=46
))
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels