1234
1234

Reputation: 241

Find element by parent class and child text

I have web element shown below

enter image description here

need to click on element 'class = dxnb-gr' and child have text "Leave details"

driver.find_element_by_xpath(".//*[@class='dxnb-gr']"

would give first element with given class.

//*[(contains(text()='Leave Details')] 

would give child with particulate text

How could I combine those conditions?

Upvotes: 0

Views: 1056

Answers (2)

Vitaliy Moskalyuk
Vitaliy Moskalyuk

Reputation: 2583

xpatH for dxnb-gr that has element wit specific text inside:

//*[@class='dxnb-gr'][.//*[contains(.,'Leave Details')]]

Upvotes: 2

j.barrio
j.barrio

Reputation: 1036

Try with this xpath:

.//li[@class='dxnb-gr' and descendant::*[contains(text(),'Leave Details')]]

Get 'ul' which have a child with text 'Today'

Upvotes: 0

Related Questions