WebDriverAPI(6)
在指定元素上方进行鼠标悬浮
测试网址
http://www.baidu.com
Java语言版本实例
@Test
public void roverOnElement() {
driver.manage().window().maximize();
driver.get(url);
//找到页面链接元素赋值
WebElement link1 = driver.findElement(By.xpath("//*[@id='u1']/a[1]"));
WebElement link2 = driver.findElement(By.xpath("//*[@id='u1']/a[2]"));
Actions action = new Actions(driver);
//鼠标悬停
action.moveToElement(link1).perform();
try {
Thread.sleep(3000);
} catch (Exception e) {
e.printStackTrace();
}
action.moveToElement(link2).perform();
}
在指定元素上方进行鼠标左键和释放的操作
测试网址
http://www.w3school.com.cn/tiy/t.asp?f=html5_ev_onmousedown
Java语言版本实例
@Test
public void mouseClickAndRelease() {
driver.manage().window().maximize();
driver.get(url);
//找到ifram框架的位置
driver.switchTo().frame(1);
WebElement div = driver.findElement(By.xpath("//*[@id='p1']"));
Actions action = new Actions(driver);
//按住鼠标左键不释放
action.clickAndHold(div).perform();
try {
//暂停2秒可以看到左键持续点击的文字变为红色
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
//松开鼠标
action.release(div).perform();
try {
//暂停2秒可以看到松开鼠标,字体变为绿色
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
WebDriverAPI(6)的更多相关文章
- WebDriverAPI(7)
查看页面元素的属性 测试网址 http://www.baidu.com Java语言版本API实例 @Test public void getWebElementAttribute() { dri ...
- WebDriverAPI(10)
操作Frame页面元素 测试网址代码 frameset.html: <html> <head> <title>frameset页面</title> &l ...
- WebDriverAPI(9)
操作JavaScript的Alert窗口 测试网址代码 <html> <head> <title>你喜欢的水果</title> </head> ...
- WebDriverAPI(4)
单击某个元素 采用元素id.click()方法即可 双击某个元素id.doubleClick 操作单选下拉列表 测试网页HTML代码 <html> <body> <sel ...
- WebDriverAPI(2)
操作浏览器窗口 被测网址http:http://www.baidu.com Java语言版本的API实例代码 String url = "http://www.baidu.com" ...
- WebDriverAPI(8)
判断页面元素是否存在 测试网址 http://www.baidu.com Java语言版本API实例 @Test public void testIsElementPresent(){ driver. ...
- WebDriverAPI(5)
将当前浏览器截屏 测试网址 http://www.baidu.com Java语言版本实例 @Test public void captureScreenInCurrentWindows() { dr ...
- WebDriverAPI(3)
获取页面的Title属性 被测网址http:http://www.baidu.com Java语言版本的API实例代码 String url = "http://www.baidu.com& ...
- WebDriverAPI(1)
访问某网页地址 被测网址http:http://www.baidu.com Java语言版本的API实例代码 方法一: @Test public void visitURL(){ String bas ...
随机推荐
- Mybatis Blob和String互转,实现文件上传等。
这样的代码网上有很多,但是本人亲测有bug, 下面是我写的代码.望参考 @MappedJdbcTypes(JdbcType.BLOB) public class BlobAndStringTypeHa ...
- VS2010 MFC对话框程序用CButtonST给按钮添加图标
也许是VS版本的关系,CButtonST中的BCMenu两个文件是无法编译通过的. 1.拷贝下载的CButtonST(我下载的v3.9)中的BtnST.h和BtnST.cpp文件到自己项目目录下. ...
- PythonWEB框架之Flask--2
10.请求扩展 1 before_request 类比django中间件中的process_request,在青丘收到之前绑定一个函数做一些事情 #基于它做用户登录认证 @app.before_req ...
- 在使用html5的video标签播放视频时为何只有声音却没有图像
在使用html5的video标签播放视频时为何只有声音却没有图像? 答:使用格式化工厂转个编码就行了,MP4有3种编码,mpg4(xdiv),,mpg4(xvid),avc(h264)转换成H264编 ...
- 2018.10.09 NOIP模拟 路途(递推+矩阵快速幂优化)
传送门 签到题.(考试的时候写挂爆0) 令AiA_iAi表示邻接矩阵的iii次幂. 于是就是求Al+Al+1+...+ArA_l+A_{l+1}+...+A_rAl+Al+1+...+Ar. ...
- 2018.09.10 loj#10172. 涂抹果酱(状压dp)
传送门 三进制状压感觉有点难写啊. 不过这题状态转移方程挺简单的. 就直接f[i][j]表示前i行第i行状态为j时的选法总数,分情况转移就行了. 代码: #include<bits/stdc++ ...
- [转]一个CMake编译问题的解决过程
问题的提出 公司的一个power-pc平台的产品,有个协议进行了修改,过程中出现了比较奇怪的情况.直接将修改后的动态库下载到设备上(原始设备是有文件系统和其他的依赖文件的,相当于部分更新应用),设备和 ...
- 解决yum安装时 Cannot retrieve repository metadata (repomd.xml) for repository
打开/etc/yum.repos.d/CentOS6-Base-163.repo 将下面的baseUrl的地址换成网上最新 # CentOS-Base.repo## The mirror system ...
- node.js初步总结
一:先上一段代码 process.argv.forEach(function (val, index, array) { console.log(index + ":" + ...
- C++和Python混合编程
为何人工智能(AI)首选Python?读完这篇文章你就知道了:https://blog.csdn.net/qq_41769259/article/details/79419322 C++调用Pytho ...