如何使用Protractor/Senium将鼠标移动到任意点
How to move the mouse to an arbitrary point using Protractor/Selenium
是否可以将鼠标移动到屏幕上的任意坐标/相对于Protractor测试中的元素?我看到有人建议Java用户使用Robot,但我当然不能在JavaScript中使用它。
我自己想好了。。。只是深入研究了Protractor和Selenium文档。以下是一些示例代码:
it('should pan plots when you click and drag', function() {
var plot0 = element(by.css('.plot > canvas'));
browser.actions()
.mouseMove(plot0, {x: 100, y: 100}) // 100px from left, 100 px from top of plot0
.mouseDown()
.mouseMove({x: 400, y: 0}) // 400px to the right of current location
.perform();
});
我还找到了一个模拟滑动动作的解决方案。
var card = element(by.css('#card'));
browser.actions()
.mouseMove(card, {x: 100, y: 100})
.mouseDown()
.mouseMove({x: 0, y: -400})
.perform();
browser.sleep(500);
browser.actions()
.mouseUp()
.perform();
var graphDimensions = {// see [1]
Width: 0,
Height: 0
};
company_page.company_Chart_Graph().getAttribute('width')
.then(function(width) {
graphDimensions.Width = parseInt(width);
});
company_page.company_Chart_Graph().getAttribute('height').then(function(height) {
graphDimensions.Height = parseInt(height);
console.log('W' + graphDimensions.Width);
console.log('H' + graphDimensions.Height);
var plot0 = company_page.company_Chart_Graph();
browser.actions()
.mouseMove(plot0, {
x: 0,
y: 0
})
.mouseDown()
.mouseMove(plot0, {
x: graphDimensions.Width,
y: graphDimensions.Height
})
.mouseUp()
.perform();
browser.driver.sleep(23000);
company_page.company_ReportDownload().click();
browser.driver.sleep(23000);
});
[1] :http://testingalert.com/
相关文章:
- js:停止鼠标移动
- Zingchart-平移键和鼠标移动
- 在鼠标上触发鼠标移动'的当前位置
- 当用户将鼠标移到屏幕/图表上时,自动滚动将暂停.如果鼠标移动停止,自动滚动将再次恢复
- 如何在谷歌地图上用鼠标移动标记
- 如何在鼠标移动事件时更改图像的窗口中心和宽度
- 如何模仿鼠标移动和事件
- 鼠标点击不会'不起作用,鼠标移动可以
- 有没有办法提高鼠标移动的分辨率
- 如何在JS中随机化backgroundPosition而不使用鼠标移动来制作万花筒的动画
- 如何使用onmousemove函数在每次鼠标移动时更改背景图像
- 使用jQuery/CSS设置的鼠标光标在鼠标移动之前不会更改
- 在谷歌地图中用鼠标移动标记
- 在HTML5画布中绘制鼠标移动的半透明线条
- 如何使用Protractor/Senium将鼠标移动到任意点
- 防止鼠标移动对elementFromPoint的攻击
- 如果鼠标悬停得很快,Jquery鼠标移动会错过一些单元格
- 检查人员是否通过鼠标移动离开网站
- 使用鼠标移动操作选择选项
- 如何在D3Javascript中将鼠标移动到节点上时显示和隐藏节点