Search code examples
xpathrobotframeworkxpath-2.0

Button click using combination of text and id Robit framework


In robit framework i am doing a button click based on text but i want to add ID also as the page has multiple button with same text

path="//button[text()=open]

Here i want to add id also what to do ? Tried following but not worked

path="//button[text()=open, id=23]
path="//button[text()=open, @id=23]

Solution

  • path="//button[@id='23'][text()='open']"
    

    or

    path="//button[@id='23' and text()='open']"
    

    You can add as many conditions as you like, be sure to check xpath rules, they are easy.

    But reviewing your question, I'm pretty sure id's are unique in a document, you might not need anything except the ID.