Unable to detect the correct value

Hi. I am new to Katalon Studio. I am trying to read the version number but for some reason, it detected the version num as null. The version num should be v. 1.3.4.31. Can anyone help me? Thanks

you are trying to get the attribute “v. 1.3.4.31”, which doesn’t exist, which therefore returns null
what you likely want to use is WebUI.getText()

Possibly you want this:

result = WebUI.verifyElementText(
            findTestObject('Object Repository/PLS Atafu/Page_Log in - FSG Atafu (Back Office Terminal)/h3_v. 1.3.4.31),
            "v. 1.3.4.31",
            FailureHandling.STOP_ON_FAILURE)

Or, the following might be simpler

result = WebUI.verifyElementPresent(
            findTestObject('Object Repository/PLS Atafu/Page_Log in - FSG Atafu (Back Office Terminal)/h3_v. 1.3.4.31),
            10,
            FailureHandling.STOP_ON_FAILURE)

Hi Kenzie, unfortunately, nothing is printed out

in that case, try
result=WebUI.getAttribute(to, “value”)
if that still doesn’t work, i’m out of ideas

What is the xpath that you are using to get the “h3_v. 1.3.4.31” element?
//h3[@class="version"]

Is this the only “h3 version” on the page?

Also, you should address the error messages about your “Timeout” that are the red items in your output. Just change them to 10. It doesn’t actually take 10 seconds each and you don’t get the error message.

And, unless you need to use the result from the “getText()”, I would go with the method that @kazurayam has given you:

WebUI.verifyElementText(findTestObject('PLS Atafu/Page_Log in - FSG Atafu (Back Office Terminal)/h3_v. 1.3.4.31), "v. 1.3.4.31")

The value printed out is still null

Hi Kazurayam,

Yes I want to read the value and compare it to check if the version num is correct. So I tried the verify element text method but this error is shown.

=============== ROOT CAUSE =====================
Caused by: com.kms.katalon.core.exception.StepFailedException: Actual text ‘’ and expected text ‘v. 1.3.4.31’ of test object ‘Object Repository/PLS Atafu/Page_Log in - FSG Atafu (Back Office Terminal)/h3_v. 1.3.4.31’ are NOT matched.

This is the xpath /html/body/form/div[3]/div[2]/div[2]/div[1]/div[2]/section/h3[2]

I think it is the only h3 version on the page. Is there anyway for me to confirm this?

Thanks for the advice but may i know how do i change the error message about “Timeout” to 10? Sorry I am new to this.

Yes i need the result to compare and check if the version num is correct but someone it keep reading it as null

  1. The fragment h3[2] suggests that in the HTML there are 2 or more h3 tags.
  2. But you wrote: the only h3.

This contradiction suggests either of:

  1. The xpath is wrong.
  2. You are not careful enough.

I can not tell which is the case.

Possibly the following XPath expression is better, provided that there are only 2 h3 elements in the page.

//h3[2]

The double slashes (//) is an abbreviate syntax in XPath expression.

  • //para selects all the para descendants of the document root and thus selects all para elements in the same document as the context node

See W3C XPath 1.0 Spec section 2.5.

Or the following tutorial:

https://www.guru99.com/xpath-selenium.html#18

You have displayed some of your code in your question above and within your statement:

WebUI.verifyElementPresent(findTestObject(…), 0)

The timeout value is the 0 (zero). Change the zero value to 10, so it becomes:

WebUI.verifyElementPresent(findTestObject(…), 10)

That will stop the red warnings from displaying in your Console log.

If you hover your mouse over the method, verifyElementPresent, a popup will display with information on the method, such as what parameters are expected.

I tried this but it still show actual text is ’ '.

Alright. Thanks for the info.

Does the HTML has any <iframe> element?

If yes, you need to switch the context by

@jeev527

As @kazurayam said, ensure if the page has Frame or not.

  1. Open your application in chrome browser. And right click on the element and check to see if the context menu has “View Frame Source” is available. If so, the element is available in frame.

  2. The below attribute’s can be used to get text:

result=WebUI.getAttribute(to, “value”)
result=WebUI.getAttribute(to, “title”)
result=WebUI.getAttribute(to, “data-bind”)
result=WebUI.getAttribute(to, “innerText”)
result=WebUI.getAttribute(to, “outerText”)
result=WebUI.getAttribute(to, “textContent”)
result=WebUI.getAttribute(to, “innerHTML”)