[Selenium] WebDriver 操作 HTML5 中的 drag/drop
以 jQuery UI 官方网站元素测试,地址:http://jqueryui.com/draggable/
示例:
package com.learningselenium.html5;
import java.util.NoSuchElementException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
public class testActionDragAndDrop{
WebDriver driver = new FirefoxDriver();
private boolean isElementPresent(By by){
try{
driver.findElement(by);
return true;
}catch(NoSuchElemention e){
return false;
}
}
@Before
public void setUp() throws Exception{
driver.get("http://jqueryui.com/draggable/");
}
@Test
public void testActionDragAndDrop() throws Exception{
//switchto().frame 来切换焦点到iframe.demo-frame
driver.switchTo().frame(driver.findElement(By.className("demo-frame")));
Thread.sleep(3000);
if(! isElementPresent(By.xpath("//div[@id='draggable']"))){
Trhead.sleep(3000);
}
WebElement draggable = driver.findElement(By.xpath("//div[@id='draggable']"));
new Actions(driver).dragAndDropBy(draggable,200,10).build().perform();
Thread.sleep(10000);
}
@After
public void tearDown() throws Exception{
driver.quit();
}
}
[Selenium] WebDriver 操作 HTML5 中的 drag/drop的更多相关文章
- [Selenium] WebDriver 操作 HTML5 中的 video
测试播放,停止播放 http://www.videojs.com/ 示例: package com.learningselenium.html5; import static org.junit.As ...
- [Selenium] 操作 HTML5 中的 Canvas 绘制图形
测试 http://literallycanvas.com/ 以 Chrome Driver 为例阐述,通过 Actions 在 Canvas 上绘制一个封闭图形.对于 Canvas 上的操作,推荐 ...
- Selenium Webdriver——操作隐藏的元素(三)switchTo().frame()
在web 应用中经常会遇到frame 嵌套页面的应用,页WebDriver 每次只能在一个页面上识别元素,对于frame 嵌套内的页面上的元素,直接定位是定位是定位不到的.这个时候就需要通过switc ...
- selenium webdriver操作各浏览器
描述 本文主要是针对Chrome 62 , firefox57 ,和IE11 三个版本的操作.相关的driver .可点击以下链接.所有的driver 建议放在浏览器的目录下,本文中所有的driver ...
- Java中通过Selenium WebDriver定位iframe中的元素
转载请注明出自天外归云的博客园:http://www.cnblogs.com/LanTianYou/ 问题:有一些元素,无论是通过id或是xpath等等,怎么都定位不到. 分析:这很可能是因为你要定位 ...
- Selenium Webdriver——操作隐藏的元素(二)display属性
有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...
- Selenium Webdriver——操作隐藏的元素
有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...
- Selenium Webdriver——操作隐藏的元素display属性
有时候我们会碰到一些元素不可见,这个时候selenium就无法对这些元素进行操作了.例如,下面的情况: 页面主要通过“display:none”来控制整个下拉框不可见.这个时候如果直接操作这个下拉框, ...
- Selenium webdriver 操作日历控件
一般的日期控件都是input标签下弹出来的,如果使用webdriver 去设置日期, 1. 定位到该input 2. 使用sendKeys 方法 比如: 但是,有的日期控件是readonly的 比如1 ...
随机推荐
- golang log日志
写入日志文件 func main() { file, err := os.Create("test.log") if err != nil { log.Fatalln(" ...
- Hihocoder 1561 观光旅行(启发式合并+贪心)
题目链接 Hihocoder 1561 首先对原图求$MST$ 我们发现某条边成为某两个点的关键路径的必要条件是这条边是最小生成树的树边. 所以我们求$MST$的同时进行启发式合并. 把$size$小 ...
- Neo4j 第六篇:Cypher语法
Cypher是图形数据库查询语言事实上的标准. 一,Cypher类型系统 Cypher支持的类型系统分为三类:属性类型,复合类型和结构类型. 1,属性类型 属性类型:Integer.Float.Str ...
- Spring Boot使用Schedule实现定时任务
适用的工具是:Schedule 集成步骤: 1.开启Schedule支持 package com.jsoft.springboottest.springboottest1; import org.sp ...
- 深入研究Clang(五) Clang Lexer代码阅读笔记之Lexer
作者:史宁宁(snsn1984) Clang的Lexer(词法分析器)的源代码的主要位置例如以下: clang/lib/Lex 这里是基本的Lexer的代码: clang/include/cla ...
- IE 扩展调用主窗体中的函数
IE 扩展调用主窗体中的函数 在函数名前加上 parentWindow 就可以.如: <script> var doc = external.menuArguments.docum ...
- Yii Criteria常用方法(select,join,where,日期,)
$criteria = new CDbCriteria; //select $criteria->select = '*';//默认* $criteria->select = 'id,n ...
- C++ primer 模板与泛型编程
继续浏览c++ primer 看到模板与泛型编程这章.就顺便把这几节的代码综合了下,对一个Queue队列模板的实现 贴一下代码(看完书.自己敲,忘记了哪再看下书) #include <ostre ...
- AJAX核心XMLHTTPRequest对象
老早就写好了总结.今天整理发表一下. XMLHttpRequest对象是AJAX的核心技术,XMLHttpRequest 是XMLHTTP 组件的对象,通过这个对象.AJAX能够像桌面应用程序一样仅仅 ...
- openwrt: patch-dtb
dts的概念是linux kernel中的,跟openwrt的关系不大.只是恰好在学习openwrt的时候碰到了这个东西,所以记录在openwrt名下. patch-dtb openwrt对arch/ ...