metametagirl
unread,Apr 28, 2009, 9:00:22 PM4/28/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to selenium-users...@googlegroups.com
Hi,
I'm using Selenium RC with Python and Perl. I'd like to extract an 'href' attribute from multiple nodes, but when I use get_attribute(), I only get the 'href' attribute of the first node found.
For example, the locator I am using is:
>>> locator = '//div[@class="info"]/p/a'
This locator evaluates to 40 nodes (this is the expected value) in my XPather Browser.
Also, I can use Selenium to extract this same count:
>>> sel.get_xpath_count(locator)
u'40'
My attribute locator is the same as the locator, with the 'href' attribute:\\ >>> attribute_locator = '//div[@class="info"]/p/a@href' However, when I try to use get_attribute(), I would like to get all 40 href's, but I only get the first one: \\ >>> sel.get_attribute(attribute_locator) u'p_10153_12605_04647333000P?vName=Appliances&cName=Refrigerators&sName=Bottom+Freezers'
Can someone suggest an alternate XPath to get the result I want, or an alternate Selenium API method would work?I do have a functioning workaround, which uses indexes into the XPath nodes to get all 40 href's, though I find this unwieldy and error-prone, and it seems to defeat the purpose of using XPath in the first place. Any help is appreciated,metametagirl