Test cases are failing with error "Unable to click on object" & "Unable to find the element located by 'By.xpath:" when running scripts using Azure Pipeline

Hello,
My test cases are running fine in my local. However, when running the same test case in Azure Pipeline which is running on a remote server, I’m getting lots of errors “Unable to click on object” & “Unable to find the element located by 'By.xpath:”
Because katalon scripts are running in console mode I can’t see what is happening and it’s returning below errors. I tried taking a screenshot, which is returning a blank screen. Please help me to identify the issue and its solution.
Let me know if you need more information.

Solution tried:

  • I have already WebUI.delay(10) statement after before launching the website.

  • Maximized the window

  • The authentication step is showing Passed successfully with both format WebUI.openBrowser(‘https://username:Password@test.abcd.net/’)
    &
    WebUI.authenticate(‘https://test.abcd.net/’, ‘username’, ‘password’, 30, FailureHandling.OPTIONAL)

Log Report

2021-01-11 16:27:15 - [TEST_STEP][PASSED] - abcd.MostlyUsed.launch_abcd(): Taking screenshot successfully

2021-01-11 16:27:16 - [MESSAGE][INFO] - Starting ‘Chrome’ driver

2021-01-11 16:27:16 - [MESSAGE][INFO] - Action delay is set to 0 milliseconds

2021-01-11 16:27:20 - [MESSAGE][WARNING] - FFmpeg was not installed! Browser Recording will be disabled. Please follow this document to install FFmpeg first: https://docs.katalon.com/katalon-studio/docs/screenshots-videos.html#browser-based-recorder

2021-01-11 16:27:21 - [MESSAGE][PASSED] - Browser is opened with url: ‘https://username:Password@test.abcd.net/

2021-01-11 16:27:22 - [MESSAGE][PASSED] - Current window maximized

2021-01-11 16:27:32 - [MESSAGE][PASSED] - Delayed 10 second(s)

2021-01-11 16:27:33 - [MESSAGE][PASSED] - Taking screenshot successfully
[[ATTACHMENT|C:\newagent\_work\13\s\Reports\20210111_162655\All_Page_Accessible_TestCases\20210111_162702\1610400453083.png]]
Showing Blank screen
2021-01-11 16:27:33 - [MESSAGE][PASSED] - Taking screenshot successfully
[[ATTACHMENT|C:\newagent\_work\13\s\Reports\20210111_162655\All_Page_Accessible_TestCases\20210111_162702\1610400453471.png]]

2021-01-11 16:27:38 - [MESSAGE][INFO] - Refreshing

2021-01-11 16:27:38 - [MESSAGE][PASSED] - Refresh successfully

2021-01-11 16:27:39 - [MESSAGE][PASSED] - Taking screenshot successfully
[[ATTACHMENT|C:\newagent\_work\13\s\Reports\20210111_162655\All_Page_Accessible_TestCases\20210111_162702\1610400459060.png]]
Showing Blank screen
2021-01-11 16:27:39 - [TEST_STEP][PASSED] - println(abcdID): null

2021-01-11 16:27:40 - [TEST_STEP][FAILED] - abcd.MostlyUsed.search_And_OpenAMember(abcdID): com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Dashboard_page/Search’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Dashboard_page/Search’
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.ClickKeyword.click(ClickKeyword.groovy:76)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)
at abcd.MostlyUsed.search_And_OpenAMember(MostlyUsed.groovy:69)
at abcd.MostlyUsed.invokeMethod(MostlyUsed.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at TC01_Access_MemberInfo_Page_WithoutError.run(TC01_Access_MemberInfo_Page_WithoutError: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:394)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:385)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:364)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:356)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:251)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:203)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:152)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:95)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:157)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1610400422806.run(TempTestSuite1610400422806.groovy:39)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Dashboard_page/Search’ located by ‘(//a[@class=‘main’][contains(text(),‘Search’)])[2]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1369)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:67)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.call(ClickKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.click(ClickKeyword.groovy:76)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword.execute(ClickKeyword.groovy:43)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:617)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$3.call(Unknown Source)
at abcd.MostlyUsed.search_And_OpenAMember(MostlyUsed.groovy:69)
at abcd.MostlyUsed.invokeMethod(MostlyUsed.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Script1597250062222.run(Script1597250062222.groovy:30)
… 13 more
)

2021-01-11 16:27:48 - [MESSAGE][INFO] - Unable to find the element located by ‘By.xpath: (//a[@class=‘main’][contains(text(),‘Search’)])[2]’. Please recheck the objects properties to make sure the desired element is located.

2021-01-11 16:27:48 - [MESSAGE][WARNING] - [SELF-HEALING] Failed to find element with id ‘Object Repository/Dashboard_page/Search’. Try using Self-healing.

Below is my pipeline task settings

  • task: katalonTask@0
    inputs:
    version: ‘7.8.2’
    executeArgs: ‘katalonc -noSplash -runMode=console -projectPath=“$(System.DefaultWorkingDirectory)\ABCD.prj” -retry=0 -testSuiteCollectionPath=“Test Suites/ABCD_Page_Access” -statusDelay=15 -executionProfile= “QA” -browserType=“Chrome” -apiKey=“xxxxxx-xxx-xxxxx-ooooooooooo”’

Should I download ffmpeg in the remote server and then change the system variable path? Will it record the browser action?

This may help:

Solution tried

  • The WebUI.enhancedClick method.
  • The WebUI.setViewPortSize(1920, 1080, FailureHandling.OPTIONAL) method instead of maximize.
  • Adding delay 120s.

I’m still getting “Unable to find the element located by 'By.xpath:” errors, and the take screenshot is returning blank screens.
The video folder is blank. The test report has a video step but do not know where to find the video. (I have screen recorder option turn on and Record video during execution is checked. The test cases are running in an Azure remote server)
Please help

Hi, I am having the same issue. When I run similar tests within Katalon on my local machine, the tests run successfully. However when I run them through a pipeline, i get the following error.

Test Cases/Portal/Tier 1/Feature Tests/Camera Management/Add cama (787) FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Device enrolment/input_Enter your camaact code_code’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Device enrolment/input_Enter your camaact code_code’
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.EnhancedClickKeyword.click(EnhancedClickKeyword.groovy:94)
at com.kms.katalon.core.webui.keyword.builtin.EnhancedClickKeyword.execute(EnhancedClickKeyword.groovy:42)
at com.kms.katalon.core.keyword.internal.KeywordExecutor.executeKeywordForPlatform(KeywordExecutor.groovy:73)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.enhancedClick(WebUiBuiltInKeywords.groovy:646)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$enhancedClick$14.call(Unknown Source)
at cameraManagement.CameraManagement.activateSCP(CameraManagement.groovy:265)
at cameraManagement.CameraManagement.invokeMethod(CameraManagement.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at add cama(787):51)
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:369)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:331)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:248)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestCaseMainPhase(TestSuiteExecutor.java:191)
at com.kms.katalon.core.main.TestSuiteExecutor.accessTestSuiteMainPhase(TestSuiteExecutor.java:140)
at com.kms.katalon.core.main.TestSuiteExecutor.execute(TestSuiteExecutor.java:89)
at com.kms.katalon.core.main.TestCaseMain.startTestSuite(TestCaseMain.java:185)
at com.kms.katalon.core.main.TestCaseMain$startTestSuite$0.call(Unknown Source)
at TempTestSuite1635361211831.run(TempTestSuite1635361211831.groovy:39)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_Device enrolment/input_Enter your camaact code_code’ located by ‘id(“act_code”)[count(. | //input[@id = ‘act_code’ and @type = ‘text’ and @name = ‘code’ and @minlength = ‘7’ and @maxlength = ‘7’ and @pattern = ‘[A-Za-z0-9]’]) = count(//input[@id = ‘act_code’ and @type = ‘text’ and @name = ‘code’ and @minlength = ‘7’ and @maxlength = ‘7’ and @pattern = '[A-Za-z0-9]’])]’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1368)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:27)
at com.kms.katalon.core.webui.keyword.internal.WebUIAbstractKeyword.findWebElement(WebUIAbstractKeyword.groovy:26)
at com.kms.katalon.core.webui.keyword.builtin.EnhancedClickKeyword$_click_closure1.doCall(EnhancedClickKeyword.groovy:66)
at com.kms.katalon.core.webui.keyword.builtin.EnhancedClickKeyword$_click_closure1.call(EnhancedClickKeyword.groovy)
at com.kms.katalon.core.webui.keyword.internal.WebUIKeywordMain.runKeyword(WebUIKeywordMain.groovy:20)
at com.kms.katalon.core.webui.keyword.builtin.EnhancedClickKeyword.click(EnhancedClickKeyword.groovy:94)

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

Please see script below:

@Keyword
def actCama(manu, actCodeURL,username,password){
‘Enter username and password’
WebUI.executeJavaScript(‘window.open();’, [])
String currentWindow = WebUI.getWindowIndex()
//sleep(5000)
‘Go in to new tab’
WebUI.switchToWindowIndex(currentWindow + 1)
//sleep(5000)
WebUI.authenticate(actCodeURL, username, password, 160, FailureHandling.OPTIONAL)
switch(manu) {
case(“7”): ‘mob’
‘Click on Start act button if it is shown’
if (WebUI.waitForElementVisible(findTestObject(GlobalVariable.startActButton),20)){
WebUI.click(findTestObject(GlobalVariable.startActButton))
sleep(15000)
}
sleep(15000)
WebUI.doubleClick(findTestObject(GlobalVariable.inputActCodeMob))
WebUI.sendKeys(findTestObject(GlobalVariable.inputActCodeMob), Keys.chord(Keys.CONTROL, ‘v’))
WebUI.click(findTestObject(GlobalVariable.activateButtonMob))
break

		case("5"): 'B'
			WebUI.doubleClick(findTestObject(GlobalVariable.inputActCodeB))
			WebUI.sendKeys(findTestObject(GlobalVariable.inputActCodeB), Keys.chord(Keys.CONTROL, 'v'))
			WebUI.click(findTestObject(GlobalVariable.rButtonB))
			break

		case("4"): 'C'
			WebUI.doubleClick(findTestObject(GlobalVariable.inputActCodeC))
			WebUI.sendKeys(findTestObject(GlobalVariable.inputActCodeC), Keys.chord(Keys.CONTROL, 'v'))
			WebUI.click(findTestObject(GlobalVariable.actiButtonC))
			break
	}
	'Switch back to portal tab'
	WebUI.switchToWindowIndex(currentWindow)
}

NOTE: Since I cannot visually see where it is failing on the remote VM,after some debugging, I believe the issue is in this piece of code:

def actCama(manu, actCodeURL,username,password){
‘Enter username and password’
WebUI.executeJavaScript(‘window.open();’, [])
String currentWindow = WebUI.getWindowIndex()
//sleep(5000)
‘Go in to new tab’
WebUI.switchToWindowIndex(currentWindow + 1)
//sleep(5000)
WebUI.authenticate(actCodeURL, username, password, 160, FailureHandling.OPTIONAL)

Note that I have tried several things like adding more delays, changing the locator strategy, etc. I am still getting the same error. ALso, the same error is thrown for the cases B and C (see script).

Below is my pipeline task settings

  • task: katalonTask@0

    inputs:

     version: '8.0.5'
    
     executeArgs: '-noSplash -runMode=console -projectPath="$(Build.SourcesDirectory)\StPortal.prj" -retry=0 -testSuiteCollectionPath="Test Suites/Automation Regression Suite (2505)" -executionProfile="variables" -browserType="Chrome" -apiKey="$(apiKey)" --config -proxy.auth.option=NO_PROXY -proxy.system.option=NO_PROXY -proxy.system.applyToDesiredCapabilities=true -webui.autoUpdateDrivers=true -adoTestRunName="T-15"'

We are encountering the same issue too. Test cases run perfectly fine on local, but are failing at certain steps while running in AWS code pipeline.
Is there any solution recommended by the Katalon team on this issue?

Having the same issue too. Has anyone have work around here? Seems like there is a problem in the Katalon side.

Facing the same issue, getting StepFailedException in ADO pipeline. But the same scripts are working fine in local. can anyone suggest a solution that would be grateful.

I am also facing very similar issue. Help is appreciated

I am also encountering the same issue. Can anyone from the Katalon team help us or give us any work around? Thanks!

Hello,

Is there any solution to this issue?

I had some progress with this.
Just remove the option -runMode=console from the command.
For me it was much better this way

Same issue here :frowning:

I’ve tried:

-Adding wait for element present/clickable
-Changing xPath
-Changing xPath to CSS selector
-Recreating test object
-Changing to enhancedClick

It works locally but “Unable to click on object” in Azure DevOps