Locating elements using findElements method

By: Slav Kurochkin

//Get all the links displayed on Page
        java.util.List<WebElement> links = driver.findElements(By.cssSelector(".ctx-has-child>a"));
        //Verify there are four links displayed on the page
        assertEquals(5, links.size());
        //Iterate though the list of links and print
        //target for each link
        for(WebElement link : links)
            System.out.println(link.getAttribute("href"));
View Comments

Leave a Comment

Use markdown or basic HTML and be nice.