Simulate press hard key in protractor



  • I am using Protractor for testing my web application. During the use of the app, I want to press a hard key on the device, like the home screen, then the app will be minimized and I will see the device's home screen. After that, I want to tap again on the app, and I want to see the screen I was before tapping on the home screen key.

    • By any chance, Protractor is able to simulate this action? If not, which tool do you recommend I can integrate with Protractor?
    • Do you think it is a good approach to automate just this touch scenario?


  • Protractor supports all webdriverjs keys

    https://www.selenium.dev/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_Key.html

    HOME is one of them , you can use these in protractor using hte "protractor" global function

    protractor.key.HOME
    

    and could be used with sendKeys

     element.sendKeys(protractor.key.HOME)
    
     browser.actions().sendKeys(protractor.Key.HOME).perform();
    


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2