Unconsistent: Unable to click on object

Hi to all!
Im getting sporadically the following error:

com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item–arrow’

My code for this is fairly simple:
WebUI.click(findTestObject(‘Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item–arrow’))

The method finding the object is through Xpath (I found the xpath by copying xpath via the f12 tool in the web)
image

There’s more to the error. Please post all of it. We need to see “Caused by”

1 Like

usualy such random errors are caused by page not being fully rendered (even if the DOM may look like is full loaded)
an ‘waitForElementPresent/Visible’ or any other ‘phisical’ detection before doing the action can help in such cases to reduce the bias. you canot click on something which is just in the code intention, but not present in the actual application used.
dynamic xpath can be also a good reason to cause this.
so … more details will help in finding a solution.
those are some of the reasons i hate frontend testing

1 Like

Hi Russ, Here is the full error.

05-08-2019 08:54:32 AM Test Cases/CreateOrg

Elapsed time: 23.224s

Test Cases/CreateOrg FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item–arrow’
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: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:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$2.call(Unknown Source)
at CreateOrg.webBrowsing_CreateOrg(CreateOrg:104)
at CreateOrg.run(CreateOrg:39)
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 TempTestCase1557294862355.run(TempTestCase1557294862355.groovy:21)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (246, 404). Other element would receive the click:


(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.17763 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’
System info: host: ‘DESKTOP-ATCPP8V’, ip: ‘192.168.1.20’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.43.600210 (68dcf5eebde371…, userDataDir: C:\Users\NewUser\AppData\Lo…}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:49895}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 73.0.3683.103, webStorageEnabled: true}
Session ID: 51cafb4adc8926d610db0cad8bc3fd94
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:79)
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: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:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$2.call(Unknown Source)
at Script1555509946044.webBrowsing_CreateOrg(Script1555509946044.groovy:104)
at Script1555509946044.run(Script1555509946044.groovy:39)
… 11 more

@Ibus Thanks for your input! Regarding the rendering I really wrote in my code:

if(!WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item--arrow'),10)){
		writer.println('CreateOrg Fail - couldn\'t login with username: ' + GlobalVariable.salesUserName)
		writer.close()
		assert 'Fail Reason:'.equals('Login didnt work')
	}
	
    WebUI.click(findTestObject('Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item--arrow')) 

Also, the front end developer said he is not touching this area of code any more.
Do you have some other input?

I don’t see the error? :thinking:

Sorry, didn’t paste it by mistake. Editing the reply

Hi, do you mean that the above is the original code you wrote ? Also, try browsing through our wait APIs and see if any of it helps:
https://docs.katalon.com/katalon-studio/docs/webui-wait-for-element-clickable.html

You can type into the search bar Wait For and the try the auto-suggested results.

Cheers !

This can also be helpful (it is about Selenium and the waiting for the element to be clickable). In short, you either wait for the element to be clickable, or use JavaScript to click the element:

Hi,

Yeah that was in my original code.

I edited my code to:

 	if(!WebUI.verifyElementPresent(findTestObject('Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item--arrow'),10)){
		writer.println('CreateOrg Fail - couldn\'t login with username: ' + GlobalVariable.salesUserName)
		writer.close()
		assert 'Fail Reason:'.equals('Login didnt work')
	}
	
    WebUI.waitForElementClickable(findTestObject('Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item--arrow'),20)
    
	writer.println("got here and was clickable");
	writer.close()
	
    WebUI.click(findTestObject('Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item--arrow'))

In my log I got: “got here and was clickable” but I still get the following error:

Test Cases/CreateOrg FAILED.
Reason:
com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item–arrow’
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: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:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$2.call(Unknown Source)
at CreateOrg.webBrowsing_CreateOrg(CreateOrg:106)
at CreateOrg.run(CreateOrg:39)
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 TempTestCase1557777437854.run(TempTestCase1557777437854.groovy:21)
Caused by: org.openqa.selenium.WebDriverException: unknown error: Element is not clickable at point (246, 404). Other element would receive the click:


(Session info: chrome=73.0.3683.103)
(Driver info: chromedriver=2.43.600210 (68dcf5eebde37173d4027fa8635e332711d2874a),platform=Windows NT 10.0.17763 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: ‘3.7.1’, revision: ‘8a0099a’, time: ‘2017-11-06T21:07:36.161Z’
System info: host: ‘DESKTOP-ATCPP8V’, ip: ‘192.168.1.20’, os.name: ‘Windows 10’, os.arch: ‘amd64’, os.version: ‘10.0’, java.version: ‘1.8.0_181’
Driver info: com.kms.katalon.selenium.driver.CChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.43.600210 (68dcf5eebde371…, userDataDir: C:\Users\NewUser\AppData\Lo…}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:63829}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, setWindowRect: true, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 73.0.3683.103, webStorageEnabled: true}
Session ID: 56cfb042a79df592e4a4b014d7a28790
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:600)
at com.kms.katalon.selenium.driver.CChromeDriver.execute(CChromeDriver.java:20)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at com.kms.katalon.core.webui.keyword.builtin.ClickKeyword$_click_closure1.doCall(ClickKeyword.groovy:79)
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: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:56)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords.click(WebUiBuiltInKeywords.groovy:616)
at com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords$click$2.call(Unknown Source)
at Script1555509946044.webBrowsing_CreateOrg(Script1555509946044.groovy:106)
at Script1555509946044.run(Script1555509946044.groovy:39)
… 11 more

This is really weird, since Katalon basicly said that it is clickable, so how can it be not clickable?

Because, at the time the click attempt was made, something else was in the way:

Hey, but when Im looking at the website and nothing visible is blocking it, and when I use the website manually I never had an issue that the button was not clickable.

Hi @Tomer_Zaks

There are quiet different reasons to this exception, can you try the solutions suggested in this Stackoverflow thread ?

https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-x-y-other-elem

Cheers !

Using human eyes, this is probably true. But our eyes often miss how quickly things get rendered by a browser. Russ’s comment is critical:

It may be that in the fraction of a second needed for the page to render, there is actually something on top of your intended element. This is corroborated by the fact that you say it’s sporadic:

Whenever you get inconsistent behavior for a step between any two test runs, it’s usually indicative of a timing issue. The best way to quickly verify this would be to put a hard wait before your click, just to ensure that the page is fully rendered:

Thread.sleep(5000);
WebUI.click(findTestObject(‘Object Repository/Page_Shieldox - Wizard/img_Create a new organization and get live feedback_wizard__item–arrow’))

If it turns out that this resolves the issue, you should take the time to implement a proper wait condition before the click. (The hard wait is simply to verify that you have a timing issue in the first place.)

Thanks, I saw the solution in StackOverflow, the ideas of what is the problem were good and well explained, but the solutions were in JS so I didn’t continue on it. Does Katalon have a way to support JS? or is there a simple place that does Groovy <-> JS?

@Brandon_Hein Yes your right it did work (Thread.sleep(NN)), How do you suggest to to make an elegant solution? (I saw that maybe domcontentloaded should solve it, but this is in JS. This function waits until the whole HTML tree would be built, and just afterwards the WebApi would work, do you know such a Groovy/Katalon function?)

You can use JavaScript in Katalon/Groovy by using the WebUI.executeJavaScript API.

I would discourage you from taking that route - at least as a first resort…

  1. First you should try to deal with state changes on the page. At some point there should be something evident that leads a regular human user to believe the page is “ready”. Your task then is to teach your automation user (Katalon) to respond to that same state.

  2. If you remain unconvinced you can do that, then yes, you can indeed resort to using JS to interrogate the page to ensure it’s in a ready state. However, domcontentloaded I would avoid for the simple reason that many pages perform dynamic changes to the page immediately they detect that domcontentloaded has fired. You might well end up in a race condition and the moment you do, ask yourself, how come regular humans know when to use the page? See point 1.

In addition, you should be aware that some pages might respond well to the approach in #2 – others may not. Some web sites whose pages are built from common source may respond well, page by page, others may not. It’s a question of approach. By far the best is to teach your robot how a human does it. See #1.

Advising you as to what to do next is difficult without knowing what technology was used to build the page - angular? react? jquery? Regular vanilla JS?

Don’t give up, you’re very close.

https://docs.katalon.com/katalon-studio/docs/webui-execute-javascript.html

2 Likes

I’ll give you a little trick that I use when I’m having trouble observing how the page changes over time. It can be a bit tedious, but you can watch every step of the rendering process very closely:

1.) Perform all steps leading up to the step before the part where you’re having the issue (either manually or with your script).
2.) Open the inspector on the page you are working with by hitting F12 (or right click anywhere on the page and click “Inspect”).
3.) On the “Elements” tab, find the <body> tag and right click on it. Select break on > subtree modifications.
4.) Perform the step manually on the page. Your inspector will pause all rendering on the page.
5.) Step through the debugger and watch the page change in slow motion.

You can speed up this process if you place the breakpoint more strategically (i.e. if you know which part of the DOM will change after some action). Putting it on the <body> tag pauses after any change to the DOM.

At some point, you’ll be able to see exactly what is blocking your element. Once you do, you can write a wait condition to wait for that element to disappear; something like:

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

3 Likes

Hi Russ!

Thanks for all the help until now!
I will for now try to use the Thread.Sleep(int) as long as it works, and domcontentloaded. I do understand what you mean therefore I do want to use a more elegant way. You asked for the technology that was used, after asking the front end developers they said:
For style: TypeScript scss
Code: JS
Using .ViewFile in the NodeJS frameWork.

Thanks! your input gave me a deeper understanding that I think will help me later on