如何在量角器上按 Ctrl+单击?
我尝试了以下奇怪的组合,但它们都不起作用:
I have tried weird combination as the following, but none of them are working:
var ptor = protractor.getInstance();
ptor.actions().mouseMove(node).keyDown(ptor.Key.CTRL).sendKeys(ptor.Key.CLICK).perform();
推荐答案
你需要链接 mouseMove()
, keyDown()
和 click()代码>:
You need to chain mouseMove()
, keyDown()
and click()
:
var elm = element(by.id('my_id'));
browser.actions()
.mouseMove(elm)
.keyDown(protractor.Key.CONTROL) // COMMAND for Mac
.click()
.perform();
通过单击链接在 Chrome 上对其进行了测试 - 在新选项卡中打开一个链接.
Tested it on Chrome by clicking on a link - opens up a link in a new tab.
请注意,从 protractor 1.5 开始,应该使用全局 browser
对象代替 protractor.getInstance()
,请参阅 重大更改.
Note that, starting with protractor 1.5, there is a global browser
object that should be used instead of protractor.getInstance()
, see Breaking Changes.
相关文章