Href attribute is empty when choosing binding using xpath

I have several links on the page that look like this:

<a class="plant_detail_link" href="plants/O7-01111"><h3>O7-01111</h3></a>

I can select all of these links on my page with the following xpath:

//a[@class='plant_detail_link']

I can normally retrieve attributes, such as the class of each link:

//a[@class='plant_detail_link']/@class

But when I try to use the same method to retrieve the values ​​of the href attribute, I get an empty list:

//a[@class='plant_detail_link']/@href

Does anyone have any idea why this might be?

image detailing xpath developer chrome console

EDIT:

See the full html page here - http://pastebin.com/MAjTt86V

+4
source share
1 answer
, . [index].value, . , $x for href , - .

, $x- "" :

$x("//a[@id='nav-questions']/@href")
> []
$x("//a[@id='nav-questions']/@href")[0].value
> "/questions"

- , :

var links = $x("//a[@target='_blank']/@href");
var linkArr = []; 
for (i in links) { linkArr.push(links[i].value)}

:

function getHref(selector, value, $x) {
var links = $x("//a[@"+selector+"='"+value+"']/@href");
var linkArr = []; 
for (i in links) { linkArr.push(links[i].value)}; 
return linkArr; }

getHref("target","_blank", $x);

, , chrome [index].value:

$x,("//a[@id='nav-questions']/@href")
> "//a[@id='nav-questions']/@href"

xpath, , .

0

All Articles