Random getAllLinksOnCurrentPage failures

Code: list = WebUI.getAllLinksOnCurrentPage(false, )

I’m getting random failures with getAllLinksOnCurrentPage. Often time, it’ll just work. 10% of the time, I’ll get this:

Test Cases/Other and GDPR/Verify all links FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to get all links on the page https://mysite.com/stuff
	at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:48)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.stepFailed(WebUIKeywordMain.groovy:65)
	at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:27)
	at com.kms.katalon.core.webui.keyword.builtin.GetAllLinksOnCurrentPageKeyword.getAllLinksOnCurrentPage(GetAllLinksOnCurrentPageKeyword.groovy:85)
	at com.kms.katalon.core.webui.keyword.builtin.GetAllLinksOnCurrentPageKeyword.execute(GetAllLinksOnCurrentPageKeyword.groovy:39)
	at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:56)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.getAllLinksOnCurrentPage(WebUiBuiltInKeywords.groovy:3694)
	at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$getAllLinksOnCurrentPage$3.call(Unknown Source)
	at Verify all links.run(Verify all links:38)
	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:331)
	at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:322)
	at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:301)
	at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:293)
	at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:227)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:114)
	at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:105)
	at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
	at TempTestCase1554492507948.run(TempTestCase1554492507948.groovy:21)

================

Any ideas?

As a general rule of thumb, when you’re getting inconsistent behavior, it’s more often than not a timing issue.

Try putting a hard delay in before you make the call:

WebUI.delay(5)
list = WebUI.getAllLinksOnCurrentPage(false, [])

If this leads to more consistent behavior, then you should replace the delay with a proper wait condition.

Also, is there any more to that error log? Can you post the whole thing?