Unable to click on object (kindly help)

Hello Everyone,

I’m new to automation testing and my test case is failing to select a radio button option for a question to move forward. Please help and find the below log.

I recorded the complete flow, so I have 3 questions on a screen with next button, the system executes 1st and 2nd question, but fails on 3rd one.

Error log:

Unable to click on object ‘Object Repository/Page_UI Online/label_Yes’ (Root cause: com.kms.katalon.core.exception.StepFailedException: Unable to click on object ‘Object Repository/Page_UI Online/label_Yes’
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$1.call(Unknown Source)
at ufacts testing 1.run(ufacts testing 1:35)
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(TestCaseMain.java:105)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1559245619158.run(TempTestCase1559245619158.groovy:21)
Caused by: com.kms.katalon.core.webui.exception.WebElementNotFoundException: Web element with id: ‘Object Repository/Page_UI Online/label_Yes’ located by ‘By.xpath: //div[@id=‘ctl00_ctl00_cphMain_cphMain_rbAgree’]/div/label’ not found
at com.kms.katalon.core.webui.common.WebUiCommonHelper.findWebElement(WebUiCommonHelper.java:1097)
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:77)
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$1.call(Unknown Source)
at Script1559245107537.run(Script1559245107537.groovy:35)
… 11 more
)

katalon do the steps with determinate speed, sometimes is faster than the web page, you try to give a time between the step with the keyword “delay”.

katalon have many keyword to do that but delay is the most simple.

It’s hard to say what’s wrong, but I’d make sure your xpath is correct.

Delay did not work, seems like my Xpath is wrong -

Unable to find the element located by ‘By.xpath: //div[@id=‘ctl00_ctl00_cphMain_cphMain_rbAgree’]/div/label’. Please recheck the objects properties to make sure the desired element is located.

Delay didn’t help

@APOORVAK1992 You might need to create the object manually. Use Google Chrome extension called “choropath”

to find an xpath and you will see option to test it at same time. If xpath doesn’t work try different attributes like class or ID.

Also if you can paste the HTML here of the object somebody might be able to help you

I figured out the problem, the website i test on has lot of questions with radio button options (Yes/No), so when I record the application. Katalon studio maps the ‘Yes/No’ option that’s selected for all the questions to a single label as label_Yes or Label_No with the same Xpath object. So is there a way to fix this ? or should I manually create labels and assign objects to it.

I think it would be best to create objects manually with correct selectors.

You’re free to alter the stored xpaths, if that’s what you’re asking. You can create TestObjects by hand, copy one to create another slightly different one…

Try it. Post back if you get stuck.

                        Questions                               My answer                          Katalon studio
  1. Where you born on Earth - 1)Yes 2) No Yes creates label_Yes and
    path - abcd
  2. Are you hungry - 1) Yes 2) No No creates label_No and
    path - qwer
  3. Are you alive - 1) Yes 2) No Yes creates label_Yes and
    path - abcd

When I record the web app, it creates same label name and assigns the same path as question 1 and 3 above. So the control gets stuck at question 3 as its path is different but it was assigned the same label and path as Q1

So one way to fix it is create a new test object and assign right path to it, But my application has lot of questions which has Yes/nO QUESTIONS, so its time consuming Process. So is there a easy way to fix it , so that during recording, katalon assigns different paths to different questions ?.

The easiest way (for me) to do that would be to write code that loops over the elements. The code would build the correct selectors “live” at runtime. No TestObjects, just code.

Sorry, I’m not able to do that for you. Perhaps @hpulsford would like to take a shot at it.

So im probably not the best person to ask, still a bit of a novice :laughing:. But just from reading a bit of this post, cant see why it wouldnt work for you. Just index the buttons on the page so it knows which one to select.

<input type="submit" id="button" value="Edit"/>
<input type="submit" id="button" value="Edit"/>
<input type="submit" id="button" value="Edit"/>
By.xpath("(//input[@type='submit'])[0]")  ---> To Click 1st Button
By.xpath("(//input[@type='submit'])[1]")  ---> To Click 2nd Button
By.xpath("(//input[@type='submit'])[2]")  ---> To Click 3rd Button

Now the route Russ has suggested would save you alot of time, especially as by the sounds of it these buttons are across your whole application. Me personally i cant help you further with that, as im not really sure where i would start.