consider following HTML:
<div id='a'>
<div>
<a class='click'>abc</a>
</div>
</div>
I want to click abc, but the wrapper div could change, so
driver.get_element_by_xpath("//div[@id='a']/div/a[@class='click']")
is not what I want
i tried:
driver.get_element_by_xpath("//div[@id='a']").get_element_by_xpath(.//a[@class='click']")
but this would not work with deeper nesting
any ideas?
Check this blog by Martin Thoma. I tested the below code on MacOS Mojave and it worked as specified.
HTML
You could use the XPATH as :
output
That said your Python code should be as :