Dror
Dror

Reputation: 5495

How can I compound/combine the webdriver locator?

If I have this structure:

<Employees>
    <Employee id="3">Tom</Employee>
    <Employee id="3">Meghna</Employee>
</Employees>

How can I use locators with the wait.until(..) command to hold till employee with Id="3" and text="Tom" exist?

Upvotes: 0

Views: 2902

Answers (3)

snigdha
snigdha

Reputation: 26

Try with the below xpath

//Employee[@id='3'][contains(text(),'Tom')]

Upvotes: 0

dmr
dmr

Reputation: 556

//Employee[@id='3' and normalize-space()='Tom']

Upvotes: 1

Madhan
Madhan

Reputation: 5818

Go with text() in xpath to find elements by text

//Employee[@id='3'][text()='Tom']

Upvotes: 2

Related Questions