Selenium Webdriver finding an element in a sub-element

If you start an XPath expression with //, it begins searching from the root of document. To search relative to a particular element, you should prepend the expression with . instead:

element2 = driver.find_element_by_xpath("//div[@title="div2"]")
element2.find_element_by_xpath(".//p[@class="test"]").text

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)