Is it possible to output the contents of Verify Text Present webUI to a Global Varialbe?

Is it possible to output the contents of Verify Text Present webUI to a Global Varialbe?

I want to write a script that searches for a particular string of text. For example:

Verify Text Present Input 20,000.00 Output (globalvariable)

when I try this I get an error:
:x: Test Cases/OL-Family/OLIE/Verification Scripts/Ensure PYQ4 Total Revenue matches prereading FAILED.
Reason:
groovy.lang.MissingPropertyException: No such property: ProfitLosspyq4Number for class: internal.GlobalVariable

any help would be greatly apprecitated

Paul

@Paul_Smith1 A verifyTextPresent returns a boolean value, either true or false, as long as that is what you want.

First, create your global in the profile you’re using:

Then…

GlobalVariable("ProfitLosspyq4Number") = 
  WebUI.verifyTextPresent( /* your test object here */ )

I am assuming you wanted a variable called ProfitLosspyq4Number but you didn’t make it very clear.

Are you looking for a specific string with in the given string?

Thanks for your response.

Overview: What I am trying to accomplish is to search a page for a string which in my case happens to be a number. and then stick that number into a global variable called ProfitLossspyq4Number

If the number is unique to that page and always same and also are you providing the number in your testobject? if that so
then your testobject should have xpath as
//*[contains(text(),‘number’)].

But if you have to read that number on that page from an element then you have to use getText() of that testObject

Here is a snipet of code:

GlobalVariable.ProFormapyq4TR = WebUI.getText(findTestObject(‘OLFamily/OLIE/SideBar/ProFormaPYQ4TotalRevenue’))

WebUI.comment(GlobalVariable.ProFormapyq4TR)

I would like to print out the contents of the Global variable: ProFormapyq4TR however the comment does NOT return the contents of the variable to the console:

Here is a console snipet after running the script: You can see the comment returns a blank.

2020-04-22 10:19:13.711 DEBUG re PYQ4 Total Revenue matches prereading - 6: comment(ProFormapyq4TR)
2020-04-22 10:19:13.713 INFO c.k.k.c.keyword.builtin.CommentKeyword -

I set the selection method of the object to attributes instead of xpath:

As you can see the text shows the number in the “Detect object by”

Here is a code snipet of my scripty trying to output text to a global variable using verify text present:

GlobalVariable.pyq4PLReport = WebUI.verifyTextPresent(’$18,394.2’, false)

WebUI.comment(GlobalVariable.pyq4PLReport)

  1. I created the GlobalVariable in my profile - thanks for that information
  2. when I run the script I get an error in the console log: Here is a snipet from the console:

2020-04-22 10:41:57.692 DEBUG re PYQ4 Total Revenue matches prereading - 3: pyq4PLReport = verifyTextPresent("$18,394.2", false)
2020-04-22 10:41:58.813 DEBUG re PYQ4 Total Revenue matches prereading - 4: comment(pyq4PLReport)
2020-04-22 10:41:58.828 ERROR c.k.katalon.core.main.TestCaseExecutor - :x: Test Cases/OL-Family/OLIE/Verification Scripts/Ensure PYQ4 Total Revenue matches prereading FAILED.
Reason:
groovy.lang.MissingMethodException: No signature of method: static com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.comment() is applicable for argument types: (java.lang.Boolean) values: [true]
Possible solutions: comment(java.lang.String), collect(), collect(groovy.lang.Closure), collect(java.util.Collection, groovy.lang.Closure)

Thanks for the help!

Paul

This will store the innerText of an HTML element - NOT the value of an HTML text box (<input type="text"> etc).

GlobalVariable.ProFormapyq4TR = WebUI.getText(findTestObject(‘OLFamily/OLIE/SideBar/ProFormaPYQ4TotalRevenue’))

If that’s what you want to do, then your global variable must be set to “string” in the profile, not boolean.

In your next post you are using it to store a boolean:

GlobalVariable.pyq4PLReport = WebUI.verifyTextPresent('$18,394.2', false)

which you then try to pass to WebUI.comment which is expecting a string, NOT a boolean, that is why you are receiving an error.

Paul, try to be clear about what you’re trying to achieve.

  1. Do you want to capture the dollar amount in a variable?
  2. Do you want to capture the true/false presence state of a specified dollar amount?

You seem to be unclear as to what you want to actually do.

  • If the dollar amount is KNOWN at the start of the Test Case, then we can write suitable code for that.
  • If the dollar amount is UNKNOWN at the start of the Test Case, then we can write suitable code for that scenario.

So the key question is, WHERE is the dollar amount? Do you know it before the Test Case begins?