Set text operates as click and set text

Hi Husnah,

Using Katalon’s sendKeys function:

Add this import to your test file:

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile 

Then send the keys to the textField Test Object:

Mobile.sendKeys(textField, "My Value"); 

Using Appium’s sendKeys function:

If that doesn’t work, you can try using Appium’s sendKeys function directly:

Add these import statements to the top of your test file:

import io.appium.java_client.android.AndroidDriver
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.mobile.keyword.internal.MobileDriverFactory

Then tap the textField Test Object to open the keyboard and send the keys using Android’s keyboard:

int timeout = 5 // timeout in secondsMobile.tap(textField, timeout)
AndroidDriver<?> driver = (AndroidDriver<?>) MobileDriverFactory.getDriver()
driver.getKeyboard().sendKeys("My Value")

Using a wrapper function from katalon-mobile-util library:

Finally, if that’s a lot to type each time you want to set the text on a field, you can try using this open source library, which has some convenience functions for handling Text Fields:

https://github.com/detroit-labs/katalon-mobile-util#textfield

You can access a built version of the library here:

https://github.com/detroit-labs/katalon-mobile-util#installation

For info on how to add a third party library to you Katalon test project, see the docs:

https://www.katalon.com/resources-center/tutorials/import-java-library/

Hope this helps,

Chris

1 Like