Close IOS keyboard by tapping ‘Done’ in Appium & webdriverio

Onur Polattimur
1 min readMay 21, 2021

--

If you are using Appium with webdriverio client to test your web application on IOS emulator using safari browser and want to close the keyboard by clicking the ‘Done’ button, you are in right place!

You might have gone through several forums until reaching this post and none of them might have the right solution for you. I did a lot of research on official documentation and discussion platforms and I got nothing.

A screenshot from ‘em’
A screenshot from ‘em’

Here is my case, I needed to click the ‘Done’ button that is above the keyboard.
Nor browser.hideKeyboard()or browser.hideKeyboard('pressKey', 'Done') didn’t work for me.

Here is the solution:

Here is the reason:

When you test your web application on safari, there are 2 contexts. The first one is NATIVE_APP and the second one is your web application. Because we want to click the element that belongs to IOS, we need to switch the context to NATIVE_APP.

Also, if you want to tap the move-up and move-down buttons you can use this method.

🐣

--

--