-1

Is there anyway to dismiss the iPhone keyboard or disable it from popping up at all while Appium tests are being run?

driver.hideKeyboard() doesn't work, half the time a "DONE" or "RETURN" button isn't present and I can't just tap randomly on the screen because I can not guarantee that the code won't accidentally tap a link or active element.

I don't understand why it doesn't just function like on Android and just never display the keyboard when using driver.sendKeys().

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
cdub
  • 330
  • 4
  • 19

2 Answers2

0

I've noticed the same and did a workaround by doing it like an actual user and clicking on the hide keyboard button. You might want to add a check to only click if the element is visible to avoid trying to close the keyboard when it's not there.

driver.findElement(By.xpath("your_keyboard_close_button")).click();
valies
  • 96
  • 5
  • Some field elements dont have a keyboard close button – cdub Jan 26 '23 at 14:32
  • If the keyboard is shown, you can check the close button of that keyboard its element selector via the Appium Inspector for example. – valies Jan 26 '23 at 14:37
  • not every instance of the iOS keyboard has a close button.... – cdub Jan 26 '23 at 15:48
  • There must be something to close/hide the keyboard, no? Or some other user action that might close the keyboard, perhaps by pressing Done on the keyboard? – valies Jan 26 '23 at 18:33
0

had the same issue.

you can basically try to fix it in two ways:

  • click "return" button on keyboard (if available)
  • use tap method from TouchAction to tap somewhere on screen, but just make sure that tapping in that spot hides the keyboard