I need to get a transaction number off the screen -- How do I do it?

I have a web app where I submit a file and a transaction # is returned. I’m trying to get this number. I understand that I need to use getText, but when I use the Katalon Spy, the object I get has the actual Transaction number as part of it’s identifier. Under the Captured Objects section, it lists h3_Your file was successfully uploaded and is now submission 69409. The Selected Locator states //dev[@id=‘ajaxessage’]/h3.

In my script I have below, but of course this can not be found. What can I do to get the $ 69409?

SubmissionNumber = WebUI.getText(findTestObject(‘Page_All Notifications/h3_Your file was successfully uploaded and is now submission’))

I’m having a lot of trouble understanding what your problem actually is:

getText and the Spy tool are unrelated things.

Try something like…

String text = getText(findTestObject("your/test/object"))
String lastword = text.split(/\s+/)[text.length - 1]
println "Last word: " + lastword

You have to choose other property to select your object, can you inspect the object with the navigator and show us the object html?

I’m using Spy tool to get the object name that can be used in the findTestObject method. So when I use getText, I have to use it on some object. The object is dynamic including the Transaction number, thus can’t use it.

Here is it from Google Development tools the div id is ajaxMessage and I’m looking for the 69412 value. Not certain if the upload below actually works or not.

Capture

I don’t do xpath but the CSS selector you need is:

#ajaxMessage>h3

If your TestObject uses that selector, then getText with be able to retrieve the whole text. Then use the code I posted earlier.

make a object with this property

1 Like

I added the object as you suggested. Transaction Response with the following properties (text and tag).


The script I have states:
submissionNumber = WebUI.getText(findTestObject(‘Transaction Response’))
I get the following error:
Unable to get text of object ‘Object Repository/Transaction Response’ …
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Transaction Response’ located by ‘By.xpath: //h3[(starts-with(text(), ‘your file was successfully uploaded’) or starts-with(., ‘your file was successfully uploaded’))]’ not found

I’m pretty new obviously, I don’t know goovy yet, I will have to learn it. I do have perl, awk, sed, bsh, powershell under my belt.

Thanks in advance, if your able to help me over this hurtle. I apologize for my only basic skills in this arena.

1 Like

the text have to be exactly as the html code, you can copy directly if you want.

the Y is in lowercase and must be in upper case, sorry was my mistake too, if it doesnt work we can find others ways to locate the object.

But the text is dynamic. It changes every time I submit a file. Wait. I may have missed that. Sorry. Let me look into it.

1 Like

all the text? you only need the no dynamic part that why we use “star with” and no “equal”, you dont have to take the number part.

Yeah. I was lazy and just copied your text. Once upper case. It worked. Now my next step is now I think I have it in a private variable. I need to do something with it. Back to the references. Thank you so much.

1 Like

no problem buddy, sorry If my last response sounds rude I dont speak english, If you need more help let me know it.