Vinyasjain77
Vinyasjain77

Reputation: 31

How to find a complex( Parent+ child) xpath on selenium java

enter image description hereI need to a find an element on my webpage that has same tags as every other element and hence I need to find the xpath based on the title of the sub-section[parent].

Below is the html code of the webpage:enter image description here

Basically I want to find an element inside the li tag based on the Scheduled text on the above image. The id attribute on the li tag is dynamic and hence we need to traverse it based on the Scheduled text in the webpage. Please let me know how it can be done.

Upvotes: 0

Views: 53

Answers (2)

undetected Selenium
undetected Selenium

Reputation: 193338

To locate the first <p> element with text as Santoshi Jewargi - 5959 Broadway, The Bronx, NY - Weeding with respect the the element with text as Scheduled you can use the following :

//strong[text()='Scheduled']//following::div[1]//ul[@class='list-group']/div[@draggable='true']/li[@class='list-group-item']//p

Upvotes: 0

Sooraj
Sooraj

Reputation: 585

Tr with the below Xpath:

//strong[text()='Scheduled']/../following-sibling::div//li

hope this works ;)

Upvotes: 1

Related Questions