Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't get the value of an attribute with Selenium RC using xpath

I'm trying to get the first href attribute in a page using Selenium RC (in Python):

sel.get_text("xpath=//@href")

this returns an empty string.

However, an identical xpath on the same page inside Firefox (using the "View XPath" extension) yields the correct value.

I've tried fiddling with it, but the same happens for other attributes (eg @class) -- is there something awfully wrong with selenium or am I overlooking something trivial here?

like image 501
GJ. Avatar asked Dec 02 '25 09:12

GJ.


1 Answers

Solved by using selenium's get_attribute e.g. sel.get_attribute("xpath=//a@href") for a nodes.

like image 60
GJ. Avatar answered Dec 04 '25 23:12

GJ.