How to verify specific section of Windows App text matches the Set Text input?

Hello,

I’m pretty new to Katalon, but I’m curious if I can check if a block of text generated by a Windows application I’m testing contains the text I initially provided as input via “Set Text” from a data variable.

I’ve tried getting the text but the contents are saved as the “locator” within the application and I’m not sure if I can access them for testing.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testng.keyword.TestNGBuiltinKeywords as TestNGKW
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

Windows.startApplicationWithTitle(‘C:\Program Files\ ------NAME OF APPLICATION’,
‘’)

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Message Search’))

Windows.setText(findWindowsObject(‘BDAR3/Message Search’), ‘BDAR’)

Windows.doubleClick(findWindowsObject(‘Object Repository/BDAR3/BDAR Message’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Terrain Description’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Field 1’))

Windows.setText(findWindowsObject(‘BDAR3/Field 1’), Terrain Description)

Windows.doubleClick(findWindowsObject(‘Object Repository/BDAR3/ListItem(1)’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Show Preview’))

Windows.getText(findWindowsObject(‘Object Repository/BDAR3/Text’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Hide Preview’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/Validate Form’))

Windows.click(findWindowsObject(‘Object Repository/BDAR3/OK’))

You can do something similar like this suggestion. You just need to change the WebUI keywords from the solution to Window keywords.

You need to either capture the value from the getText, (see the link in @chen.lee above) because otherwise the “gotten” text goes nowhere, or use the getText in a comparison, like below.

assert  Windows.getText(findWindowsObject('Object Repository/BDAR3/Text')) == "your text here"