Thursday, 26 December 2013

Selenium - How to read URL of a link

Selenium code to get URL is as follows -

    1. Find the link as a Web Element using findElement() method

                      WebElement Lnk_URL =  driver.findElement(By.id("Lnk"));

    2. Get URL value using  "href" attribute
                      
                       String URL = Lnk_URL.getAttribute("href");

No comments:

Post a Comment