Note: Driver is an instance of Webdriver, XPath is an XPath string for an element, and is used in this article to position the element in an XPath manner.
1, the right mouse button click operation:
Actions action = new actions (driver);
Action.contextclick (Driver.findelement (By.xpath (XPath)));
2, the left mouse button double-click Operation:
Actions action = new actions (driver);
Action.doubleclick (Driver.findelement (By.xpath (XPath)));
3, the left mouse button to press the operation:
Actions action = new actions (driver);
Action.clickandhold (Driver.findelement (By.xpath (XPath)));
4, the left mouse button lifting operation:
Actions action = new actions (driver);
Action.release (Driver.findelement (By.xpath (XPath)));
5, move the mouse to the element operation:
Actions action = new actions (driver);
Action.movetoelement (Driver.findelement (By.xpath (XPath)));
6. Combined Mouse Action (drag the target element onto the specified element):
Actions action = new actions (driver);
Action.draganddrop (Driver.findelement (By.xpath (XPath)), Driver.findelement (By.xpath (XPath)));
7. Combined Mouse Action (drag the target element into the specified area):
Actions action = new actions (driver);
Action.draganddrop (Driver.findelement (By.xpath (XPath)), Xoffset,yoffset);
8, the keyboard press operation:
Actions action = new actions (driver);
Action.keydown (Driver.findelement (Getby ()), key); Note: Key is an instance of keys, and a F1 key is instantiated as Keys.f1
9, Button release operation:
Actions action = new actions (driver);
Action.keyup (Driver.findelement (Getby ()), key);
"Reprint" Webdriver commonly used mouse/keyboard operation