如何在量角器上按 Ctrl+单击?

How can I do a Ctrl+Click on protractor?(如何在量角器上按 Ctrl+单击?)

本文介绍了如何在量角器上按 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.

这篇关于如何在量角器上按 Ctrl+单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何在量角器上按 Ctrl+单击?

基础教程推荐