iOS - Determine Keyboard is Shown

Hi,

Is there a way to determine iOS keyboard is shown?

Please see screenshot.

http://postimg.org/image/7tj4hgn7j/

Thanks.

1 Like

simulator only: !driver.findElements(MobileBy.className(“UIAKeyboard”)).isEmpty();

2 Likes

Can try driver.findElement(By.name(“Search”)); It will return keyboard button WebElement or will throw NoSuchElementException in case keyboard is not present.

What language are you using?

Test development in C#, iOS app.

I will go with solution provided by “amedvedev” as class Names are more reliable in iOS. But as said it works only on Simulator.

!driver.findElements(MobileBy.className(“UIAKeyboard”)).isEmpty();
OR
!driver.findElements(By.className(“UIAKeyboard”)).isEmpty();

isEmpty() is important other wise method will throw exception and test execution will break.

1 Like

Just on the chance someone comes across this. I’m using ruby but @driverAppium.is_keyboard_shown seems to work fairly well to determine whether the keyboard is visible.