I have an element on a page which has more than one xpath based on some criteria.
I want to create a single testobject containing all the xpaths of that element in OR clause.
So, If first xpath is not found, it will look for the 2nd xpath.
Thank you very much for your topic! It may take a little while before Katalon team member or others forum members respond to you.
In the meantime, you can double-check your post to see if you can add any extra information i.e. error logs, HTML codes, screenshots, etc. Check out this posting guide to help us help you better!
There are multiple solutions, it really depends on your specific situation.
It depends on how you apply them and how your DOM looks like, so the solutions will not accidentally match additional other elements with the other path when the first case is found.
You can write it directly in the xpath with the OR operator. This will select every element that fulfills the first part AND every element that fulfills the second part separately.
example: //*[@id='site-logo' or @id='site-logo-1']
Other or operator |
example: //book/title1 | //book/title2
You can do it by using a variable in the xpath, and you specify in your code for example with an if statement which to use.
example: //*[@id='${variable}'] Use variables in Web test objects | Katalon Docs
These are really simple examples, but without seeing the specifics it is hard to say.
Hope this helps!