Using xpath to get Link anchor text?

346 views
Skip to first unread message

arya

unread,
Sep 28, 2009, 8:26:10 PM9/28/09
to selenium-users...@googlegroups.com
Hello

Lets say we have some html like the following

<html>
&nbsp; <head> <title>Main</title></head>
&nbsp; <body>
&nbsp;&nbsp;&nbsp; <a href="page.html">TEXT LINK</a>
&nbsp; </body>
<html>


Would it be possible to extract "TEXT LINK" using xpath?


Best Regards

rajiv

unread,
Sep 28, 2009, 11:54:06 PM9/28/09
to selenium-users...@googlegroups.com
Try to use This

{code:html}<tr>
<td>storeText</td>
<td>//a[contains(@href, 'page.html')]</td>
<td>linkname</td>
</tr>
<tr>
<td>echo</td>
<td>{code}${linkname}</td>
<td></td>
</tr>

storeText | //a[contains(@href, 'page.html')] | linkname
echo | ${linkname}

arya

unread,
Sep 29, 2009, 4:22:04 PM9/29/09
to selenium-users...@googlegroups.com
Thanks, but I forgot to mention that I'm using Perl with selenium [http://search.cpan.org/~lukec/Test-WWW-Selenium/lib/WWW/Selenium.pm] and there is no "storeText" method in the perl module. Is there anyway to do it in Perl?

Reply all
Reply to author
Forward
0 new messages