I am trying to index the results returned by xpath. For instance:
xpath = '//a[@id="someID"]'
may return multiple results. I want to get their list. I thought what to do:
numOfResults = sel.get_xpath_count(xpath)
l = []
for i in range(1,numOfResults+1):
l.append(sel.get_text('(%s)[%d]'%(xpath, i)))
will work because something like this with firefox Xpath checker works:
(//a[@id='someID'])[2]
returns the second result.
Ideas Why Behavior Will Be Different And How To Do It With Selenium Thanks
source
share