Search code examples
androidgoogle-chromeprotractorappium

Protractor + Appium hide android keyboard in chrome


  • MacOS Sierra 10.12.4
  • Node - v6.9.5
  • Appium - 1.6.0
  • Protractor - 5.1.2

I am completely new to using appium and just got the basic setup working with the android emulator running the google chrome browser. The problem that I'm running into is that the soft keyboard I believe is in the way so a simple action like logging in doesn't work off the bat b/c when it types in my credentials the keyboard is in the way so it doesn't properly click the sign in button. The workaround that I found was clicking the text field after sending keys to get rid of the soft keyboard. I was hoping that there was an easy way to just disable the keyboard for automated testing. The other option that I hope I don't have to do would be overloading the sendKeys function to check if it's on mobile and click the textfield after sending keys. Any help or suggestions on how to solve this issue is appreciated.

Possible Solution

I have found this ExtendedWebDriver info from the protractor api reference page but I'm having difficulty finding any examples of successfully implementing it to use the function hideSoftKeyboard


Solution

  • Alright so I couldn't get it to work using protractors implementation of ExtendedWebDriver. But they said you can also use wd-bridge

    // configuring wd in onPrepare
    // wdBridge helps to bridge wd driver with other selenium clients
    // See https://github.com/sebv/wd-bridge/blob/master/README.md
    onPrepare: function () {
      var wd = require('wd'),
        protractor = require('protractor'),
        wdBridge = require('wd-bridge')(protractor, wd);
      wdBridge.initFromProtractor(exports.config);
    }
    

    then in my spec file in the login function I was able to hide the keyboard after it entered the password using the global wdBrowser

    this.passwordFld.sendKeys(password).then(() => {
      wdBrowser.hideDeviceKeyboard();
      this.signInBtn.click();
    });