Xpath: how to find a div using the elements in the div


i writed this line of code (i know it isn’t correct)

driver.find_element(By.XPATH, '//div[contains(div[contains(string(),"Example_String"))]').click()

i need to find the div that contains a div that contains a string. how to can i do that?

sorry for grammatical errors, i’m not english­čą▓


I’m not so sure about JaSON’s solutions, neither of them doesn’t look like a valid xpath to me…

try this, it should work for you:

//div[div[contains(text(), 'Example_String')]]

Answered By – Marek

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published