Sunday, 29 September 2013

Getting a child element with Selenium and Python

Getting a child element with Selenium and Python

I have this HTML:
<div id = "d029384">
<span>......</span>
</div>
and my code:
elem = browser.find_elements_by_xpath("//div[contains(@id,'d')]")
except the div isn't working for what my program is doing. I need to be
more specific. I need the span element instead. How can I get the span
element? Each div has an id that is d + numbers. I need those numbers so
that's why I used that xpath but I don't know how to make the final
WebElement point to the span and not to the div.
Anyone know?

No comments:

Post a Comment