Explanation of Python Keyboard Events

  • 2021-12-12 09:06:36
  • OfStack

Directory keyboard event 1, delete key BACKSPACE2, enter key ENTER3, select all operation CTRL + a4, copy operation CTRL + c5, paste operation CTRL + v6, cut operation CTRL + x7, undo operation CTRL + z8, Shift + Ctrl + Home If the cursor is at the end, it is equivalent to performing CTRL + a summary

Keyboard event

Go straight to the bag without talking too much nonsense


from selenium.webdriver.common.keys import Keys

1. Delete key BACKSPACE


driver.find_element_by_xpath(  element  ).send_Keys(Keys.BACK_SPACE)

2. Enter ENTER


 driver.find_element_by_xpath(  element  ).send_keys(Keys.ENTER)

3. All selection operation CTRL + a


driver.find_element_by_xpath(  element  ).send_Keys(Keys.CANCEL,"a")

4. Copy Operation CTRL + c


driver.find_element_by_xpath(  element  ).send_Keys(Keys.CANCEL,"c")

5. Paste operation CTRL + v


driver.find_element_by_xpath(  element  ).send_Keys(Keys.CANCEL,"v")

6. Cutting operation CTRL + x


driver.find_element_by_xpath(  element  ).send_Keys(Keys.CANCEL,"x")

7. Undo CTRL + z


driver.find_element_by_xpath(  element  ).send_Keys(Keys.CANCEL,"z")

8. Shift + Ctrl + Home If the cursor is at the end, it is equivalent to executing CTRL + a


content_ele.send_keys(Keys.SHIFT, Keys.CONTROL, Keys.HOME)

Summarize

This article is here, I hope to give you help, but also hope that you can pay more attention to this site more content!


Related articles: