selenium 使用action进行鼠标,键盘操作
2017-01-04 15:38
531 查看
<!--test.html-->
<html> <head> <title>Set Timeout</title> <script> </script> </head> <body> <input type="text" name="lastname"> <input id = "alert" value = "alert" type = "button" onclick = "alert('欢迎!请按确认继续!');"/> <input id = "confirm" value = "confirm" type = "button" onclick = "confirm('确定吗?');"/> <input id = "prompt" value = "prompt" type = "button" onclick = "var name = prompt('请输入你的名字:','请输入你的名字'); document.write(name) "/> </body> </html>
public static void main(String[] args) throws InterruptedException, IOException { //定义一个前缀文件夹 String string="非常有才华,有能力,有技术!!!!!!!"; int i=0; WebDriver dr = new FirefoxDriver(); String url = "file:///C:/Users/leixiaojiang/Desktop/test.html"; dr.get(url); //新建一个action Actions action=new Actions(dr); //操作 WebElement element=dr.findElement(By.name("lastname")); WebElement element1=dr.findElement(By.id("alert")); while (i<10000) { action.sendKeys(element,string+i).perform(); i++; } action.moveToElement(element1); action.click().perform(); }
//拖放的组合操作 Action dragAndDrop = builder.clickAndHold(someElement).moveToElement(otherElement).release(otherElement).build().perform(); 其他鼠标或键盘操作方法可以具体看一下API 里面的 org.openqa.selenium.interactions.Actions 类
相关文章推荐
- 玩转python selenium鼠标键盘操作(ActionChains)
- 玩转python selenium鼠标键盘操作(ActionChains)
- python selenium鼠标键盘操作(ActionChains)
- selenium之 玩转鼠标键盘操作(ActionChains)
- selenium之 玩转鼠标键盘操作(ActionChains)
- selenium之 玩转鼠标键盘操作(ActionChains)
- 总结Selenium WebDriver中一些鼠标和键盘事件的使用
- selenium webdriver学习(十三)------------如何利用Actions类模拟鼠标和键盘的操作
- 使用Struts的Action来通过Hibernate对数据库进行增、删、改、查四项操作
- selenium webdriver(4)---模拟鼠标键盘操作
- Python Selenium 键盘和鼠标操作
- Selenium 鼠标和键盘操作
- selenium2+python模拟鼠标键盘操作类ActionChains的API
- selenium webdriver学习(十三)------------如何利用Actions类模拟鼠标和键盘的操作
- Selenium WebDriver中一些鼠标和键盘事件的使用
- Python Selenium 学习笔记(三)键盘和鼠标操作
- selenium webdriver学习(十三)------------如何利用Actions类模拟鼠标和键盘的操作
- 编写一个脚本,对至少三个以上记事本窗口做相同操作,对任意一个窗口进行手动操作,其余窗口由脚本执行相同步骤的键鼠操作,记得是键盘操作+鼠标操作。
- 一个java3d程序,作为熟悉3d技术的基础(可以使用鼠标对场景内的3d对象进行操作)
- Java使用Robot操作键盘和鼠标