Kevin Zhao
Kevin Zhao

Reputation: 2143

Chrome element inspector Xpath with @href won't show link text

I am trying to get url from a website's html and here is the Xpath code I tried for StackOverflow's landing page:

$x('//*[@id="question-summary-30429261"]/div[2]/h3/a/@href')

I think it should return the text after the equal sign in the following statement:

href=xxxx

but it doesn't. It just returns null. I tried Googling this question but no answer came up. Does someone know the reason why text @href won't show me the link text?

Upvotes: 1

Views: 2042

Answers (1)

Kirill Polishchuk
Kirill Polishchuk

Reputation: 56202

This should work:

$x('//*[@id="question-summary-30429261"]/div[2]/h3/a')[0].getAttribute('href')

Upvotes: 1

Related Questions