Venkatesh
Venkatesh

Reputation: 231

how to find the xpath for the below code

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

Answers (3)

Tom Trumper
Tom Trumper

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

Raghavendra
Raghavendra

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

Saritha G
Saritha G

Reputation: 2608

You can use this:

 //a[@class='home_fb_logo']

Upvotes: 1

Related Questions