Typing on Soft Keyboards

The TypeText command can be used to enter text on any SUT. In most situations, this is the simplest and most straightforward approach. However, on mobile devices, it does not exactly imitate the user experience. In some situations it is desirable to type against the soft keyboard on a mobile device instead of injecting the TypeText events directly into the system. This is especially useful if your application has a custom soft keyboard that you want to test, or if you just want to imitate the user experience more closely.

Typing on the Soft Keyboard of a Mobile Device

This scenario is also a great example of where modularization of scripts is helpful. The code to type against a soft keyboard can be broken out into a handler and stored in a separate script or handler library. Once this has been created, that code and all of the associated images can be stored in a helper suite and reused over and over again. Every time you need to interact with a soft keyboard on a mobile device, simply call the related code, and pass the string you want to type to that handler.

Typing on a Soft Keyboard using Swipe Type

Typing on a soft keyboard can be done with the method shown above, where each letter key is tapped individually, imitating the way a user types on the keyboard. However, swipe type can also be imitated with Eggplant Functional.

While this is a less common method of typing on keyboards, it can be important to test swipe type capability either to more closely mimic the user experience, or to verify swipe type capability on a custom soft keyboard. Additionally, this method used to script swipe-typing can be modified and applied to other kinds of shape drawing, such as when using a pattern to unlock a device.

Multiple Word Swipe Type

When doing a swipe type with multiple words, it is important to make sure that the spaces between the words are being created properly. A standard swipe type keyboard is likely to insert the spaces automatically if no spaces are manually added, but the spaces can also be added in order to ensure correct typing of the desired text.

A line of code like the one below can be used to tap the space key after each word is swipe typed on the keyboard.

Tap "SpaceKey" //This taps an image of the space key and can be inserted at the end of the handler being called, or in the calling script after each word is passed to the handler.

The calling script will need to pass each word to the handler individually, though the handler could also be set up to iterate through a list, and a list could be passed instead.


This topic was last updated on August 19, 2021, at 03:30:51 PM.

Eggplant icon Eggplantsoftware.com | Documentation Home | User Forums | Support | Copyright © 2022 Eggplant