|
Java |
Python |
Ruby |
Mouse events |
Right-click |
Actions action = new actions (driver); Action.contextclick (InputBox). Build (). Perform () |
Actionchains (Driver). Context_click (Element). Perform () |
Driver.action.context_click (Element). Perform |
Double click |
Action.doubleclick (Element). Build (). Perform () |
Actionchains (Driver). Double_click (Element). Perform () |
Driver.action.double_click (Element). Perform |
Left click |
Action.clickandhold (Element). Build (). Perform () |
Actionchains (Driver). Click_and_hold (Element). Perform () |
Driver.action.click_and_hold (Element). Perform |
Drag |
Action.draganddrop (source element, target Element). Build (). Perform (); |
Actionchains (Driver). Drag_and_drop (source element, target Element). Perform () |
Driver.action.drag_and_drop (source element, target element). Perform |
Hover |
Action.movetoelement (driver.findelement (Element). Build (). Perform () |
Actionchains (Driver). Move_to_element (Element). Perform () |
Driver.action.move_to (Element). Perform |
Keyboard events |
Fallback key (ESC) |
Action.sendkeys (element, Keys.escape). Perform () |
element. Send_keys (Keys.escape) |
element. Send_keys:escape |
Keyboard F1 |
Action.sendkeys (element, KEYS.F1). Perform () |
element. Send_keys (KEYS.F1) |
element. send_keys:f1 |
Home key |
Action.sendkeys (element, Keys.home). Perform () |
element. Send_keys (Keys.home) |
element. Send_keys:home |
End key |
Action.sendkeys (element, Keys.end). Perform () |
element. Send_keys (Keys.end) |
element. send_keys:end |
Insert key |
Action.sendkeys (element, Keys.insert). Perform () |
element. Send_keys (Keys.insert) |
element. Send_keys:insert |
Delete key |
Action.sendkeys (element, Keys.delete). Perform () |
element. Send_keys (Keys.delete) |
element. Send_keys:d elete |
Delete key (Backspace) |
Action.sendkeys (element, Keys.back_space). Perform () |
element. Send_keys (Keys.back_space) |
element. Send_keys:backspace |
TAB key (TAB) |
Action.sendkeys (element, Keys.tab). Perform () |
element. Send_keys (Keys.tab) |
element. Send_keys:tab |
SPACEBAR (space) |
Action.sendkeys (element, Keys.space). Perform () |
element. Send_keys (Keys.space) |
element. Send_keys:space |
Enter (enter) |
Action.sendkeys (element, Keys.enter). Perform () |
element. Send_keys (Keys.enter) |
element. Send_keys:enter |
Shift key |
Action.sendkeys (element, Keys.shift). Perform () |
element. Send_keys (Keys.shift) |
element. Send_keys:shift |
ALT key |
Action.sendkeys (element, Keys.alt). Perform () |
element. Send_keys (Keys.alt) |
element. Send_keys:alt |
Page up key (PgUp) |
Action.sendkeys (element, keys.page_up). Perform () |
element. Send_keys (KEYS.PAGE_UP) |
element. Send_keys:p Age_up |
Page down key (PgDn) |
Action.sendkeys (element, Keys.page_down). Perform () |
element. Send_keys (Keys.page_down) |
element. Send_keys:p Age_down |
Up key (↑) |
Action.sendkeys (element, Keys.up). Perform () |
element. Send_keys (Keys.up) |
element. Send_keys:up |
Next Key (↓) |
Action.sendkeys (element, Keys.down). Perform () |
element. Send_keys (Keys.down) |
element. Send_keys:d Own |
Left (←) |
Action.sendkeys (element, Keys.left). Perform () |
element. Send_keys (Keys.left) |
element. Send_keys:enter |
Right-click (→) |
Action.sendkeys (element, Keys.right). Perform () |
element. Send_keys (Keys.right) |
element. Send_keys:left |
Select All (Ctrl + a) |
Driver.findelement (By.id ("kw")). SendKeys (Keys.chord (Keys.control, "a")) |
element. Send_keys (Keys.control, ' a ') |
element. Send_keys [: Control, ' a '] |
Copy all selection (Ctrl + C) |
Driver.findelement (By.id ("kw")). SendKeys (Keys.chord (Keys.control, "C")) |
element. Send_keys (Keys.control, ' C ') |
element. Send_keys [: Control, ' C '] |
Cut Select All (Ctrl+x) |
Driver.findelement (By.id ("kw")). SendKeys (Keys.chord (Keys.control, "X")) |
element. Send_keys (Keys.control, ' x ') |
element. Send_keys [: Control, ' X '] |
Paste all selection (Ctrl + V) |
Driver.findelement (By.id ("kw")). SendKeys (Keys.chord (Keys.control, "V")) |
element. Send_keys (Keys.control, ' V ') |
element. Send_keys [: Control, ' V '] |
Number 1 |
Action.sendkeys (element, Keys.numpad1). Perform () |
element. Send_keys (KEYS.NUMPAD1) |
element. Send_keys:numpad1 |
The corresponding package needs to be imported before calling part of the method Java: Import Org.openqa.selenium.interactions.Actions
Python: From Selenium.webdriver.common.action_chains import Actionchains From Selenium.webdriver.common.keys import keys ↓↓↓o (o ' ω′) ツ┏━┓ (knock table ~ ~ ~) Look down: In Java, you need to refer to the package that you just mentioned in mouse events and keyboard key events. Why am I not using this method in the keyboard key combination event? Because I tried many times did not succeed (if the small partners know that the method of the combination of key usage, please leave a message ~), so in the keyboard combo key event adopted another method (the method does not need to import the actions package), the method is also applicable to keyboard single-button event. |