Disclosure: New Katalon User mostly using Record function and Manual
Our site is a database that can be searched and the results refresh within an element when the user submits the query.
What we are trying to do is verify that certain text exists in the results table. The Verify Text option searches the whole page so that’s a no go since the search term exists on the page. The Verify Element Text option appears to want to match the entire text string of the element instead of just finding the word within the element.
I see there is an option for GetText and that seems to be the right path, but I don’t know how to then check that text for a single word.
You would benefit greatly from learning how to use Script view (instead of or as well as Manual view), because…
in Script, you can do something like this:
String text = WebUI.getText(findTestObject("path/to/my/test object"))
if(text.contains("Jason")) {
println("Eureka! I found Jason! :) ")
} else {
println("Sorry, Jason is not around :( ")
}
Thanks, Russ. This may be a silly follow-up question, but maybe I am just missing something elementary. The println function: can you base a pass/fail on this? Like if text.contains(“Jason”)) test case passes?
Also, any solid resources for learning to use script view? It seems fairly intuitive when looking at it, but always happy to learn more.
No. They’re typically seen in situations like that example I gave to signify “your code here” but actually doing something meaningful (e.g. the output will appear in the console in KS).
To fail a test at that point, use the KeywordUtil class markFailed or markFailedAndStop methods.
Seriously, “the water’s fine” as they say. Jump in. If you get stuck, ask here. There’s a bunch of us regulars (spread all over the globe) just itching to help
As a first step - write some tests the usual way. Check the Script view. Make changes in Manual View. Check how they appear in Script View. Repeat.
hint: skip the installation part. just go to the part where the programming stuff starts. do not be ashamed if you don’t understand everything from the begining and don’t attempt to read it in a single day.
take your time, small steps, explore, redo … learning is a continuous process
Just a quick update…I was able to accomplish this using a combination of GetText, If-Else and KeywordUtil.markFailed
result = WebUI.getText(findTestObject("path/to/my/test object")
if (result.contains('ipad')) {
println('Look, I found it!')
} else {
KeywordUtil.markFailed
}
Hopefully, this does the trick…all tests have worked accurately so far. Thanks for the help.