Selenium - 实现网页元素拖拽
2014-08-22 17:47
106 查看
Drag and Drop, 使用鼠标实现元素拖拽的操作貌似很复杂, 在Selenium中, 借助OpenQA.Selenium.Interactions.Actions类库中提供的方法, 实现起来还是比较简单的。道理如下:
1. 找到要拖拽的页面元素-源(source)。
2. 找到要释放的页面元素-目标(target), 页面显示的这个元素可能是个坑, 但是在页面代码中他就是一个元素。
3. 借助(new Actions(IWebDriver)).DragAnddrop( source, target).Perform(), 完成元素拖放操作。
示例代码:
1. 找到要拖拽的页面元素-源(source)。
2. 找到要释放的页面元素-目标(target), 页面显示的这个元素可能是个坑, 但是在页面代码中他就是一个元素。
3. 借助(new Actions(IWebDriver)).DragAnddrop( source, target).Perform(), 完成元素拖放操作。
示例代码:
// drag and drop using OpenQA.Selenium.Interactions; SIE.InternetExplorerDriver driver = new SIE.InternetExplorerDriver(); if (source != null && target != null) { // drag and drop new Actions(driver).DragAndDrop(source, target).Perform(); }
相关文章推荐
- 实现网页中元素的拖拽功能
- Javascript实现网页中元素的拖拽
- 简单网页元素拖拽实现
- Selenium实现元素的拖拽(java版)
- JavaScript实现网页元素的拖拽效果
- JavaScript实现网页元素的拖拽效果
- 网页内部元素拖拽实现
- jQuery实现网页特效之拖拽元素
- Vue通过操作Dom元素 实现 拖拽文件到网页进行文件上传【JS/JQ 原理也是一样的】
- JavaScript实现网页元素的拖拽效果
- selenium实现浏览器截屏,拖拽页面元素
- JavaScript实现拖拽网页内元素的方法
- jquery网页元素拖拽插件效果及实现
- jquery网页元素拖拽插件效果及实现
- 实现元素拖拽
- 用JS实现网页元素阴影效果的研究总结
- 用Javascript实现鼠标拖拽网页表单 (二)
- 用Javascript实现网页表单鼠标拖拽
- 用Javascript实现网页表单鼠标拖拽
- 用Javascript实现鼠标拖拽网页表单(一)