Verify Text Present (without specifying the element)

Hi, is there a way to verify if a text is present on screen? I am looking for a feature similar to Scroll to Text where you can enter a String and Katalon will scroll to that String.

I am trying to write a test case that checks the date/time is displayed on the phone is the current date/time. I have included the following in my test and the results are correct so far:

import java.text.SimpleDateFormat as SimpleDateFormat

dateLocal = new Date()
dateFormat = new SimpleDateFormat('dd MMMM yyyy')
timeFormat = new SimpleDateFormat('HH:mm')

printDate = dateFormat.format(dateLocal)
printTime = timeFormat.format(dateLocal)


I now want to check that printDate and printTime are present on the mobile device screen. I see the command Verify Element Text but this requires you to specify a Test Object. The test object on screen also includes the date and time i.e. android.widget.TextView5 - 16 April 2020 and android.widget.TextView7 - 1135 meaning it will fail because the object name no longer matches printData or printTime

I hope this is clear to understand. Any help will be appreciated. Thanks

How about WebUI.verifyTextPresent(printDate + " " + printTime, false)? This will just check if the date and time are on the page, assuming that the two items are displayed as one phrase. (I am not certain what aspect is TextView7 and TextView5 about?) If I am on the right channel of what you want, I would insert the verify text BEFORE you print out date and time.

@helpdesk - thanks for the advice. The date and time displayed are on separate lines. I added the line: WebUI.verifyTextPresent(presentDate, false) but it threw an error on this line:

com.kms.katalon.core.exception.StepFailedException: Unable to verify text '20 April 2020' is present 
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)
	at com.kms.katalon.core.webui.keyword.builtin.VerifyTextPresentKeyword.verifyTextPresent(VerifyTextPresentKeyword.groovy:83) 

The console log states: Caused by: com.kms.katalon.core.webui.exception.BrowserNotOpenedException: Browser is not opened

I assume this WebUI command does not work with Mobile - Any other suggestions?

Hi @mohammad.arif,

Actually, you can always change the test object property at any time /=)

import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.testobject.TestObjectProperty as TestObjectProperty
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import java.text.SimpleDateFormat as SimpleDateFormat

dateFormat = new SimpleDateFormat('dd MMMM yyyy')
timeFormat = new SimpleDateFormat('HH:mm')

// -----

TestObject dateObject = findTestObject('Mobile 01/android.widget.TextView5 - 16 April 2020')

TestObjectProperty dateObjectTextProperty = dateObject.findProperty('text')

String printDate = dateFormat.format(new Date())


Mobile.verifyElementText(dateObject, printDate)

// ---

TestObject timeObject = findTestObject('Mobile 01/android.widget.TextView7 - 1135')

TestObjectProperty timeObjectTextProperty = timeObject.findProperty('text')

String printTime = timeFormat.format(new Date())


// And you can also change the condiction if you want, like so:
// timeObjectTextProperty.setCondition(ConditionType.CONTAINS)

Mobile.verifyElementText(timeObject, printTime)

~ Hope this could help /=)