Saved testobjects have exact same attributes and Katalon doesn't see the ID. Please help


#1

Hello
I’m trying to write a test in which all the checkboxes inside a panel are checked and unchecked in a certain sequence. The problem is that when I save these checkboxes as testobjects every single checkbox gets the exact same tag and xpath.

image

And here are the attributes:

Naturally the test doesn’t work since Katalon can’t discern the checkboxes because all of them have the same attributes.

I tried manually adding a different ID for each checkbox but if I do that Katalon won’t find the object.
Moreover, if I inspect the elements I can see the ID of the checkbox but Katalon can’t for some reason.
Those first two checkboxes’ ID are incomesource0 and incomesource1 respectively:

image

Please help. I’m so very stuck in this problem.
Any feedback is much appreciated.


#2

did you try to have just xpath = //input[@id=‘incomeSource0’]?

also you can try to address them using value attribute

please write what you already tried …


#3

Then it’s not correct - and looking at that xpath, I wonder why anyone uses them (confession: I don’t. Ever).

If you use CSS, this is all you need:

#incomesource0

#4

@Andrej_Podhajsky I haven’t tried what you’re saying.

How do I do that? Do I have to change the whole xpath?

Thanks btw!


#5

edit in Object repository what you recorded
leave only xpath checked and change it accordingly


#6

@Russ_Thomas Thanks for replying. I don’t use CSS (at least I don’t think I am). Do I write #income0 in the selector editor? Not quite sure what you mean.


#7

parametrize the test object for the selector, and build the selector in the test script using a template, groovy is smart enough to do substitustions in gstrings, e.g.

my-selector = "#income${index}"

#8

Hello dasu07,

you can use below xpath::
//input[@id = ‘incomeSource0’ and @value=‘Salary’]
//input[@id = ‘incomeSource1’ and @value=‘Pension’]
However you could use the below one also, just another form
//input[@id = ‘incomeSource0’ ]
//input[@id = ‘incomeSource1’]

Let us know if it works or not.
I believe, they should work.
you can see below articles too.
https://www.guru99.com/xpath-selenium.html
https://www.swtestacademy.com/xpath-selenium/


#9

Hello! Thanks for replying.
So… should I replace the entire xpath in the Objext’s xPaths with //input[@id = ‘incomeSource0’ ] for example?
This is how the xpaths look right now. I’m a bit unsure as to where I need to put the value you’re mentioning
image


#10

Hi,
It’s in the Selector Editor


#11

Thank you! I changed the xpath in the selector editor but it still doesn’t work for some reason.
My checkbox is located in //button-group/div/label/input/ (?) (see pasted image) but Katalon interprets it when I save the object in //button-group/div/label/i as you can si in the xpath:position value. Do i need to change all the xpaths accordingly or just the selector?

image


#12

image

Type this:

#incomesource0

Or…

#incomesource1

“#” means “id”


#13

@dasu07 this can help you to better understand css selectors:
https://www.w3schools.com/cssref/css_selectors.asp