I used the example of using this website
If you want to create a seating test case with conditions like:
- Check whether the seat is reserved or not
- If the seat is reserved then do the next seat check
- If the seat is available then do the click action and the next action
Can you use for and if-else statements?
Please help, what is the solution for these conditions if implemented into a katalon test case
To answer your question on whether you can use for and if-else statements, then yes you can. You can also use while statement when you check on the “next seat check” until you find one that is available. You don’t need to solve the issue right away, but to implement it in stages so that it is not overpowering.
One other possible idea is to use parameterization of an element’s pathway so that you can increment the id from one number to the next.
You can use following xpath = “//div[@id=“mozila”]/div/span[not(contains(@class, “tc_seat_reserved”))]”
This xpath will find you not reserved seat from the start you dont need to add loop statements or conditions. if you are looking for only one non-reserve seat.