admin管理员组文章数量:1244303
I have a link on the webpage. I want to right click and copy the link location is it possible through selenium 1? For example I have a webpage opened and it has a link "add book" and it manually if i right click and do copy link location then it points to http://webserver/webapps/books/addbook.jsp?book_id=44_1&type=reference&promo=none
Is there a way to find out to copy the link by giving an XPath of the text :"add book" ? Or using javascript?
Thanks in advance.
I have a link on the webpage. I want to right click and copy the link location is it possible through selenium 1? For example I have a webpage opened and it has a link "add book" and it manually if i right click and do copy link location then it points to http://webserver/webapps/books/addbook.jsp?book_id=44_1&type=reference&promo=none
Is there a way to find out to copy the link by giving an XPath of the text :"add book" ? Or using javascript?
Thanks in advance.
Share Improve this question asked Nov 18, 2011 at 8:14 java_enthujava_enthu 2,3278 gold badges46 silver badges75 bronze badges3 Answers
Reset to default 7Am using bellow code to get link location (With Selenium-WebDriver and java binding) :
WebElement link = driver.findElement(By.linkText("add book"));
String linkLocatin = link.getAttribute("href");
System.out.println("Link Location "+linkLocatin);
In Selenese I use something like this:
<tr>
<td>storeAttribute</td>
<td>xpath=//a[text()="add book"]@href</td>
<td>linkToBook</td>
</tr>
<tr>
<td>echo</td>
<td>${linkToBook}</td>
<td></td>
</tr>
The Selenium-interface has a
getHtmlSource()
-method. This returns a String, on which you can apply an Xpath like this:
//a[text()="add book"]
本文标签: javaCan I get link location through seleniumStack Overflow
版权声明:本文标题:java - Can I get link location through selenium? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1740197574a2239605.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论