Reputation: 231
Trying to find the xpath for the below face book link .
<a class="home_fb_logo" target="_blank" title="facebook" href="http://www.facebook.com/chaturdn"></a>
<a class="home_tw_logo" target="_blank" title="twitter" href="http://www.twitter.com/chaturdn"></a>
<a class="home_sc_logo" target="_blank" title="soundcloud" href="http://www.soundcloud.com/chaturdn"></a>
<a class="home_go_logo" target="_blank" title="google+" href="https://www.google.com/+dnchaturvedi/about"></a>
<a class="home_yt_logo" target="_blank" title="youtube" href="http://www.youtube.com/chaturdn"></a>
<a class="home_li_logo" target="_blank" title="linkedin" href="http://www.linkedin.com/in/chaturdn"></a>
</div>
Upvotes: 1
Views: 125
Reputation: 472
To get a handle on the Facebook link
WebElement you could use either of the following XPath expressions:
//a[@class='home_fb_logo']
//a[@title='facebook']
To get the actual URL from the link
WebElement you can use the WebElement.getAttribute() method like so:
String url = element.getAttribute("href");
Upvotes: 0
Reputation: 3580
use this //*[@title="facebook"]
to get the link find the element //*[@title="facebook"]
and use getAttribute("href")
to get the link in selenium.
Upvotes: 0