How to verify text in a hyperlink?

I am trying to verify text in a hyperlink has anyone tried this?

you can use getAttribute

Sure. WebUI.getText() is your friend here.

What did you try? What happened?

I tried the gettext and it work however is it verify the text on the whole page or the results

this is the error im getting

groovy.lang.MissingPropertyException: No such property: attribute for class: Script1570204081222

WebUI.getText targets the element (and/or subelements) of the element you specify. In the example you gave, it should return the text contained in the link ( element).

What is attribute? (From that minuscule example, all I can say is it sounds like a misnomer).

Also, verifyMatch is not getText.

I think you need to state clearly what you want to achieve and what you have tried.

Hey Russ
Are you talking about this?

result = WebUI.getText(findTestObject('link_Register'))

Loosely speaking, yes. You asked about hyperlinks - HTML <a> elements. So if link-Register is a Test Object representing an <a> element, you can use getText just like in your example and result should contain all innerText from the link.

This is what Im trying to verify
the word ipad

result = WebUI.getText(findTestObject('link_Register'))
if(result.contains("IPAD")) {
  println("Cool. Everything in the world is fantastic!")
} else {
  println("Help! It's broken!!!")

This not working

result = WebUI.getText(findTestObject(‘link_Register’))
if(result.contains(result)(“IPAD”)) {
println(“Cool. Everything in the world is fantastic!”)
} else {
println(“Help! It’s broken!!!”)

in fact doesnt println either

That code will work IF you have Test Objects defined as you specified.

You should be sharing everything. We’re working almost blind here.

ok i know

this helpful?

I just noticed you changed the code I gave you. It’s broken.

the contains when i paste it gets crossed out

ignore it.

this is the error log whe I ignore the contain strike out

Test Cases/Spending Search/Keyword Search FAILED.


com.kms.katalon.core.exception.StepFailedException: Unable to get text of object

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:64)

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:26)

at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword.getText(GetTextKeyword.groovy:88)

at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword.execute(GetTextKeyword.groovy:67)

at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:60)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getText(WebUiBuiltInKeywords.groovy:888)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$getText$ Source)

at Keyword Search:45)


at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(

at com.kms.katalon.core.main.TestCaseExecutor.runScript(

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(

at com.kms.katalon.core.main.TestCaseExecutor.execute(

at com.kms.katalon.core.main.TestCaseMain.runTestCase(

at com.kms.katalon.core.main.TestCaseMain$runTestCase$ Source)


Caused by: java.lang.IllegalArgumentException: Object is null

at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(

at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$_getText_closure1.doCall(GetTextKeyword.groovy:76)

at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$

at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)

… 16 more

Which tells me (and you) link_Register is null. That is, it does not refer to any web element. Check your Test Object definition.