Script succeeds twice, then fails at random locations

I have recorded a web script and then added a few WebUI calls to it. I run the scripts using Remote sessions to CrossBrowserTesting. The script runs in Chrome, Edge, Firefox, IE successfully. Then I got it working in Safari (Mac OSX 10.14, Safari 12). Ran it twice successfully. Then I ran it two more times and it failed at different points. I will attach the script and latest error. It seems like a tool built for regression testing should be more consistent in the scripting results.

Script

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase

import static com.kms.katalon.core.testdata.TestDataFactory.findTestData

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject

import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile

import com.kms.katalon.core.model.FailureHandling as FailureHandling

import com.kms.katalon.core.testcase.TestCase as TestCase

import com.kms.katalon.core.testdata.TestData as TestData

import com.kms.katalon.core.testobject.TestObject as TestObject

import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS

import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

import internal.GlobalVariable as GlobalVariable

WebUI.openBrowser(‘’)

WebUI.navigateToUrl(‘https://tst.67thstreetbbq.com/’)

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.click(findTestObject(‘Object Repository/Page_67th Street BBQ/img’))

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.click(findTestObject(‘Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe’))

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.click(findTestObject(‘Object Repository/Page_67th Street BBQ/img_1’))

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.click(findTestObject(‘Object Repository/Page_67th Street BBQ/img_Toggle navigation_onetidHe (1)’))

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.click(findTestObject(‘Object Repository/Page_67th Street BBQ/img_2’))

WebUI.waitForPageLoad(120)

WebUI.waitForJQueryLoad(120)

WebUI.closeBrowser()

**Error on WebUI.click(findTestObject(‘Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe’)) in line 8

**11-29-2018 10:36:04 AM click(findTestObject(“Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe”))

Elapsed time: 1.395s

click(findTestObject(“Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe”)) FAILED.

Reason:

com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe’ (Root cause: org.openqa.selenium.StaleElementReferenceException: A node reference could not be resolved: Node with identifier ‘node-A8D36506-ED81-450A-A932-F442CB28CC74’ was not found

For documentation on this error, please visit: Selenium

Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’

System info: host: ‘MIKEBO-W10A’, ip: ‘10.40.110.82’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’

Driver info: com.kms.katalon.selenium.driver.CRemoteWebDriver

Capabilities {acceptInsecureCerts: false, browserName: Safari, browserVersion: 12.0, javascriptEnabled: true, platform: MAC, platformName: MAC, setWindowRect: true, webdriver.remote.sessionid: 4862EDDD-0F64-4FC0-848B-794…}

Session ID: 4862EDDD-0F64-4FC0-848B-79491C6FF11E)

at com.kms.katalon.core.keyword.internal.KeywordMain.stepFailed(KeywordMain.groovy:36)

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.ClickKeyword.click(ClickKeyword.groovy:86)

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

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

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)

at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)

at Callouts - Safari.run(Callouts - Safari:30)

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:321)

at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:312)

at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:291)

at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:283)

at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:222)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:106)

at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:97)

at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)

at TempTestCase1543509338761.run(TempTestCase1543509338761.groovy:22)

It seems like a tool built for regression testing should be more consistent in the scripting results.

Seriously, you can’t blame the tool yet – your script itself is in need of robust testing before you start blaming Katalon.

I’m assuming line 8 is:

WebUI.click(findTestObject('Page_67th Street BBQ Avoid These 10/img_Toggle navigation_onetidHe'))

Before that step, make certain the target object is ready and available to be clicked on. waitForPageLoad(120)/waitForJQueryLoad(120) isn’t going to help much with that, try…

https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-visible.html

and/or

https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-clickable.html

If you still think your code is good and it still fails on Safari, investigate why Katalon/Selenium believe the element has become stale. This error usually means that the page has updated in the background (via ajax, http fetch et al) giving new objects with identical names to the ones you had before (ie the ones you had before are now stale). To do that, perform the test by hand while watching for network events/traffic in the developer tools.

Good luck.

1 Like

Thanks for the information! Will give it a try.

Is there something similar available for mobile also. as ‘Mobile.waitForElementPresent’ is not working in my case and can’t find any option like Mobile.waitForElementClickable’ in the option list.
I am clicking on various footer options available on the screen and it actually clicking on 1st clickable object on the screen which is a calendar option. apart from it it’s taking 60-120+ seconds to execute every single step.

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

Mobile.startApplication(‘/Users/apple/Desktop/RP_iOS_builds/RP11June2019/RPMP.app’, false)

Mobile.waitForElementPresent(findTestObject(‘Footer/XCUIElementTypeButton - 1 (1)’), 10)

Mobile.tap(findTestObject(‘Footer/XCUIElementTypeButton - 1 (1)’), 0)

Mobile.waitForElementPresent(findTestObject(‘Footer/XCUIElementTypeButton (2)’), 10)

Mobile.tap(findTestObject(‘Footer/XCUIElementTypeButton (2)’), 0)

Mobile.waitForElementPresent(findTestObject(‘Footer/XCUIElementTypeButton (3)’), 10)

Mobile.tap(findTestObject(‘Footer/XCUIElementTypeButton (3)’), 0)

Mobile.waitForElementPresent(findTestObject(‘Footer/XCUIElementTypeButton (4)’), 10)

Mobile.tap(findTestObject(‘Footer/XCUIElementTypeButton (4)’), 0)

Mobile.waitForElementPresent(findTestObject(‘Footer/XCUIElementTypeButton (5)’), 10)

Mobile.tap(findTestObject(‘Footer/XCUIElementTypeButton (5)’), 0)

Mobile.delay(2)

Mobile.closeApplication()

RP%20Execution%20logs

Thanks in advance,
Abhishek