右键单击量角器 [英] right click in protractor

查看:130
本文介绍了右键单击量角器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用量角器右键单击某个元素,该元素是ag-grid中的一个单元格。

I'm trying to right click an element using protractor, the element is a cell in an ag-grid.

我正在尝试使用一些我可以找到的更早的建议是,唯一没有使我出错的建议是:

I'm trying to use some of the earlier suggestions that I could find, the only one that didn't throw me an error was the following:

browser.actions().mouseMove(elementVar).perform();
browser.actions().click(protractor.Button.RIGHT).perform();

尽管根本不右键单击。

有什么建议吗?

推荐答案

找到了答案。我真的很接近,但是对于那些要寻找这个问题的人,解决方案是:

Found an answer for that one. I was really close, but for the ones to look for this question the solution is this:

您要传递给mouseMove函数的elementVar,应该是所需的元素位置。这是什么意思?
例如,假设我们要右键单击一个名为 el的元素,我们的代码需要像这样:

the elementVar you are passing to the mouseMove function, should be the desired element location. What does it mean? For example lets say we have an element called 'el' that we want to right click on it, our code needs to be like:

async function rightClick (el) {
    loc = el.getLocation();    //get the location of the element we want to click
    await browser.actions().mouseMove(loc).perform();   //takes the mouse to hover the element
    await browser.actions().click(protractor.Button.RIGHT).perform();    //performs the right click
};

这篇关于右键单击量角器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆