Xamarin Test Cloud is now part of Visual Studio App Center! Get Started.

Text Entry

PDF for offline use
Related APIs:

Let us know how you feel about this

Translation Quality


It is very common for a test script to enter text into a user interface as a part of the test. Calabash provides several methods for text entry.

Calabash-iOS provides the following two methods:

Calabash-Android provides these three methods:

Each of these will be discussed in more details below.


keyboard_enter_text is used to enter text into a view, but the signature is slightly different on each platform

On Android the method takes a Calabash query to locate the view, and then a string with the text to enter:

keyboard_enter_text "* marked:'my_edit_view'", "Some text"

On iOS the method takes a single parameter, the text that will be input into the view. It is assumed that the view already has focus and is visible on the screen:

tap_mark 'my_edit_view'
keyboard_enter_text "Some text"

The behaviour of this method is slightly different between iOS and Android:

  • iOS – Calabash will display the soft keyboard, and then simulate presses on the keyboard.
  • Android – Calabash does not use the soft keyboard - instead it will enter text directly into the view.

Disable the Hardware Keyboard on iOS

keyboard_enter_text will fail if the iOS simulator is configured to use the hardware keyboard. Before running your Calabash tests locally, ensure that it is using the soft keyboard.


The difference between the two methods is that enter_text will check for the existence of the view before attempting text entry, for example:

keyboard_enter_text "* marked:'creditCardTextField", "1234567890123456"

Clearing Text

The clear_text method will clear the text from the view:

clear_text "* marked:'creditCardTextField'"

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.