selenium 使用action进行鼠标,键盘操作
<!--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 类
selenium 使用action进行鼠标,键盘操作的更多相关文章
- Java+selenium之WebDriver模拟鼠标键盘操作(六)
org.openqa.selenium.interactions.Actions类,主要定义了一些模拟用户的鼠标mouse,键盘keyboard操作.对于这些操作,使用 perform()方法进行执行 ...
- selenium之 玩转鼠标键盘操作(ActionChains)
用selenium做自动化,有时候会遇到需要模拟鼠标操作才能进行的情况,比如单击.双击.点击鼠标右键.拖拽等等.而selenium给我们提供了一个类来处理这类事件——ActionChains sele ...
- selenium webdriver(4)---模拟鼠标键盘操作
webdriver提供Actions来模拟鼠标悬浮.拖拽和键盘输入等操作,详细代码见org.openqa.selenium.interactions.Actions.本文通过几个实例来说明Action ...
- selenium层级定位及鼠标键盘操作
#code:utf-8 from selenium import webdriver from selenium.webdriver.common.action_chains import Actio ...
- selenium 鼠标,键盘操作
1.打开和关闭网页 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 #!/usr/bin/env python # -*- coding:u ...
- selenium模拟鼠标键盘操作
简单操作: 1.点击(鼠标左键)页面按钮:click() 2.清空输入框:clear() 3.输入字符串:send_keys()submit提交表单: 1.一般情况可以点击搜索按钮来搜索 2.也可以用 ...
- selenium webdriver从安装到使用(python语言),显示等待和隐性等待用法,切换窗口或者frame,弹框处理,下拉菜单处理,模拟鼠标键盘操作等
selenium的用法 selenium2.0主要包含selenium IDE 和selenium webDriver,IDE有点类似QTP和LoadRunner的录制功能,就是firefox浏览器的 ...
- selenuim2模拟鼠标键盘操作
有时候有些元素不便点击或者做其他的操作,这个时候可以借助selenium提供的Actions类,它可以模拟鼠标和键盘的一些操作,比如点击鼠标右键,左键,移动鼠标等操作.对于这些操作,使用perform ...
- python模拟鼠标键盘操作 GhostMouse tinytask 调用外部脚本或程序 autopy右键另存为
0.关键实现:程序窗口前置 python 通过js控制滚动条拉取全文 通过psutil获取pid窗口句柄,通过win32gui使程序窗口前置 通过pyauto实现右键菜单和另存为操作 1.参考 aut ...
随机推荐
- SEED信息安全实验系列:缓冲区溢出漏洞实验
缓冲区溢出漏洞实验 本课程详细出自http://www.shiyanlou.com/courses/231,转载请注明出处. 一.实验描述 缓冲区溢出是指程序试图向缓冲区写入超出预分配固定长度数据的情 ...
- 【译】Spring 4 @PropertySource和@Value注解示例
前言 译文链接:http://websystique.com/spring/spring-propertysource-value-annotations-example/ 本篇文章将展示如何通过@P ...
- Python中获取当前日期的格式
在Python里如何获取当前的日期和时间呢?在Python语言里,我们可以通过调用什么模块或者类函数来得到当前的时间或日期呢? 当然你可以使用时间模块(time module),该模块提供了各种和时间 ...
- NFS服务器搭建——可用于共享文件或负载均衡文件共享服务器使用
一.软件包安装 yum -y install nfs-utils rpcbind 二.服务器端配置共享目录 1. 在服务器上创建NFS共享目录:mkdir /usr/local/test 2. 设置 ...
- C++实例讲解Binder通信
binder是android里面的通信机制,这就不说它如何如何好了,Goog已经说过了,这里不多说.binder是一个面向对象的编程方法,大量使用虚函数类.最近研究binder看到一网友写的,就借鉴一 ...
- HTML5全屏(Fullscreen)API详细介绍
// 整个页面 onclick= launchFullScreen(document.documentElement); // 某个元素 launchFullScreen(document.get ...
- 【Windows编程】系列第六篇:创建Toolbar与Statusbar
上一篇我们学习了解了如何使用Windows GDI画图,该应用程序都是光光的静态窗口,我们使用Windows应用程序,但凡稍微复杂一点的程序都会有工具栏和状态栏,工具栏主要用于一些快捷功能按钮.比如典 ...
- JCIP chap3 share objects
"同步"确保了操作的原子性执行,但它还有其它重要的方面:memory visibility.我们不但要确保当一个线程在使用一个对象的时候,其它线程不能修改这个对象,而且还要保证该线 ...
- 1869: Mathematics and Geometry
这是郑州轻工业学校的一次校赛的校内选拔赛,看名字是计算几何 的题 题目地址: http://acm.zzuli.edu.cn/zzuliacm/problem.php?id=1869 Descript ...
- There is no getter for property named 'useName' in 'class cn.itcast.mybatis.pojo.User'
org.apache.ibatis.exceptions.PersistenceException: ### Error updating database. Cause: org.apache.i ...