[Mobile] Get Text


This is a companion discussion topic for the original entry at https://docs.katalon.com/katalon-studio/docs/mobile-get-text.html

Is that possible to setText into an EditText than get the value through this? I am getting an error like ‘object not found.’ :frowning:

Use getAttribute method and the object of the getAttribute that you have to give in the parameter need to save in the object repository.

The below example worked for me.

Mobile.setText(findTestObject(‘android.widget.EditText0 - hhhhhhhhhhhhh (1)’), ‘shamim’, 0)
String text= Mobile.getAttribute(findTestObject(‘android.widget.EditText0 - shamim’), ‘text’, 5) Mobile.verifyEqual(text, ‘shamim’) Mobile.closeApplication()

how can i know the code if i want to get label text on the button in the list view element?

How can I validate the “Get Text” function inside of .groovy file (Keywords file) I am seeing “groovy.lang.MissingPropertyException: No such property” exception, please go through with below example

Example:
public class abc {
@Keyword
public void sample(){
txt = Mobile.getText(findTestObject(‘ObjectLoc’), 0)
Mobile.verifyMatch(txt, ‘actualTxt’, false)
}
}