Unable to get attribute value using Selenium RC using xpath

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

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

returns an empty string.

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

I tried to work with it, but the same thing happens with other attributes (for example, @class) - is there something terribly wrong with selenium, or do I not notice something trivial here?

+3
source share
3 answers

Solved using selenium get_attribute, for example. sel.get_attribute("xpath=//a@href")for nodes.

+5
source

Selenium RC get_attribute, .

AttrValue = sel.get_attribute("//li[@id='result_0']/div/div[3]/div/a@href")

//li[@id='result_0']/div/div[3]/div/a - xpath.

xpath= .

0

, :

:

selenium.getAttribute("//input@value");
-1

Source: https://habr.com/ru/post/1749519/


All Articles