单击量角器中元素的给定坐标

编程入门 行业动态 更新时间:2024-10-28 10:33:20
本文介绍了单击量角器中元素的给定坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想点击我的 canvas 元素的特定位置,所以我编写了以下量角器代码:

I want to click on a specific location of my canvas element, so I wrote the following Protractor code:

var canvas = element(by.id("canvas")); var clickCanvas = function(toRight, toBottom) { browser.actions() .mouseMove(canvas, -toRight, -toBottom) .click(); }

toRight/toBottom 是应该进行点击的像素数,相对于画布的左上角.

toRight/toBottom are the numbers of pixels where the click should be made, relative the top left corner of my canvas.

然而,点击似乎没有在给定的坐标处执行.我从 相关问题中得到了片段 关于软件质量保证测试堆栈交换.

However, the click does not seem to be executed at the given coordinates. I got the snippet from a related question on the Software Quality Assurance & Testing stack exchange.

你能确认这个片段有效吗?你能提出替代方案吗?

Can you confirm that this snippet works? Can you suggest alternatives?

推荐答案

我做了这个工作,传递一个表示坐标的对象作为 mouseMove 的第二个参数:

I made this work, passing an object representing the coordinate as the second argument of mouseMove:

var canvas = element(by.id("canvas")); var clickCanvas = function (toRight, toBottom) { browser.actions() .mouseMove(canvas, {x: toRight, y: toBottom}) .click() .perform(); };

更多推荐

单击量角器中元素的给定坐标

本文发布于:2023-11-22 23:09:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1619283.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:量角器   坐标   单击   元素

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!