How to make protractor press the enter key?

后端 未结 6 1033
执笔经年
执笔经年 2020-12-15 15:09

I\'ve tried this:

browser.actions().keyDown(protractor.Key.ENTER).keyUp(protractor.Key.Enter).perform();

which gives the error:

<         


        
6条回答
  •  抹茶落季
    2020-12-15 15:39

    The actions() is not required.

    You can do something like:

    var input = $('#someInput');
    input.sendKeys(protractor.Key.ENTER);
    

    Update: some people have complained that you are not sending the enter to browser. If you want to do this just change your selector:

    $('body').sendKeys(protractor.Key.ENTER);
    

提交回复
热议问题