I have a site with elements of the form:
<td id="subject_23432423">content I want to read</td>
How do I use Selenium RC (with the Python bindings specifically) to read the content from all these elements? I've gone through all the commands, and while there's a lot of options to find a single element, none of the commands seem to handle lists of multiple matches. For example, I can find the content of a specific element using:
content = sel.get_text("td[@id='subject_23432423']")
but this assumes I already know the id, which I don't because it's generated dynamically.
What I would do is one of the following techniques
count = sel.get_xpath_count("xpath=//td[starts-with(@id,'subject_')]")
someArray = []
for i in count:
someArray[i] = sel.get_text("xpath=//td[starts-with(@id,'subject_')][" + i + "]")
or for a more effiecent way to use BeautifulSoup or lxml
html = sel.get_html_source()
from BeautifulSoup import BeautifulSoup
soup = BeautifulSoup(html)
#use beautifulsoup to do what you want
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With