<p>Actions action= new Actions(webdriver);</p><p>action.moveToElement(webdriver.findElement(By.cssSelector(cssSelector))).click().build().perform();//将鼠标移动到指定元素,并点击左键</p>
复制代码
2、右键单击
<p>Actions action= new Actions(webdriver);</p><p>action.moveToElement(webdriver.findElement(By.cssSelector(cssSelector))).contextClick().build().perform();//将鼠标移动到指定元素,并点击右键</p>
复制代码
3、鼠标双击
<p>Actions action= new Actions(webdriver);</p><p>action.moveToElement(webdriver.findElement(By.cssSelector(cssSelector))).doubleClick().build().perform();//将鼠标移动到指定元素,并双击左键</p>
复制代码
键盘操作
<p>Actions actionClose= new Actions(webdriver);</p><p>actionClose.keyDown(Keys.CONTROL).sendKeys("w").keyUp(Keys.CONTROL).sendKeys(Keys.NULL).perform();//火狐浏览器关闭当前标签页(ctrl+w)</p>