Hey
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.
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.
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.
Reason:
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$5.call(Unknown Source)
at Keyword Search.run(Keyword Search:45)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:337)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:328)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:307)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:299)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:233)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1570478092295.run(TempTestCase1570478092295.groovy:23)
Caused by: java.lang.IllegalArgumentException: Object is null
at com.kms.katalon.core.helper.KeywordHelper.checkTestObjectParameter(KeywordHelper.java:33)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$_getText_closure1.doCall(GetTextKeyword.groovy:76)
at com.kms.katalon.core.webui.keyword.builtin.GetTextKeyword$_getText_closure1.call(GetTextKeyword.groovy)
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.