How can I do a Ctrl+Click on protractor?

无人久伴 提交于 2019-12-05 00:49:16

问题


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();

回答1:


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();

Tested it on Chrome by clicking on a link - opens up a link in a new tab.


Note that, starting with protractor 1.5, there is a global browser object that should be used instead of protractor.getInstance(), see Breaking Changes.



来源:https://stackoverflow.com/questions/27825116/how-can-i-do-a-ctrlclick-on-protractor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!