During the automated testing process, because of the use of JavaScript, we often need to click on some of the mouse to display the menu and other elements, then need to trigger the element's mouse over events. There are two implementations of the Webdriver.
1. Use the action
Java code
- Public void movetoelement (Webdriver driver, by locator) {
- Actions builder = New actions (driver);
- Builder.movetoelement (driver.findelement (Locator)). Perform ();
- }
2. Using Sendkey
Java code
- Public void movetoelement (Webdriver driver, by locator) {
- Driver.findelement (Locator). SendKeys (Keys.down);
- }
Note: The specific use of what key, can be changed according to the actual situation. For example, the left menu may use the right arrow to exhale a submenu. You should use Keys.right
Webdriver operation is very rapid, if once moveto you can not see or is unable to carry on the operation, may add the circulation to achieve the effect.
http://uniquepig.iteye.com/blog/1703155