Automating iOS Keyboard Action keys

Hi All :slight_smile:

Question here …
How do I Automate iOS Keyboard actions keys such as “SEARCH”, “DONE”, “NEXT” etc.

I was able to do it using
driver.findElement(By.xpath("(//[@class=‘UIKBKeyplaneView’]/[@class=‘UIKBKeyView’])[5]")).click();

Is there a sexier way ?

Thanks!

Hi Liran,

I guess that the reason that you are not seeing the iOS keyboard keys in a more “sexier” :slight_smile: way is due to the fact that you are using instrumentation in your tests (Capability - instrumentApp=true)

The way to work with keyboards in iOS is to switch context to non-instrumented before you interact with the keyboard, and then switch back to your original context (Instrumented \ WEB)

Here are a list of steps that I follow when I face the same issue :

Step 1 - Appium Studio UI - Switch from instrumented to non-instrumented mode

It helps when you develop your scripts, the way to switch context in the UI is by right clicking on the screen after you open the object spy and choosing non-instrumented dump option from the context menu

Step 2 - Copy the non-instrumented property of the iOS Keyboard element

Step 3 - Switch to non-instrumented context before you click on the element

  driver.context("NATIVE_APP"); // switch to non-instrumented context
  driver.findElement(By.xpath("//*[@text='Next']")).click();
  driver.context("NATIVE_APP_INSTRUMENTED"); // back to instrumented context 
  driver.findElement(By.xpath("//*[@accessibilityLabel='loginButton']")).click();

Regards

Tom

Cool :slight_smile:

Thanks Tom for the fully detailed answer!

Cheers,
Liran

Hello Tom,
I applied ,

driver.context(“NATIVE_APP”); // switch to non-instrumented context
driver.findElement(signUp.done).click();
driver.context(“NATIVE_APP_INSTRUMENTED”); // back to instrumented context
dc.setCapability(“autoWebview”, true);

driver.context(“NATIVE_APP”) is working fine, found the non -instrument element. But after apply driver.context(“NATIVE_APP_INSTRUMENTED”) the instrumented elements are not found. though in object spy I can see that the app returned to Instrumented mode. please let me know the available solution.

Found the solution ,

driver.context(“WEBVIEW_1”) is working for me.
Thank u so much Tom.