I'm trying to get all links from a web page. I tried to use
WebDriver driver = FirefoxDriver();
List<WebDriver> elements = driver.findElements(By.tagName("a"));
But I get zero links. How can I fix this?
I need to get the part from <a href="url">. I need the URL text.
I think found what I was looking for:
List<WebElement> elements = driver.findElements(By.tagName("a"));
for (int i = 0; i < elements.size(); i++) {
System.out.println(elements.get(i).getAttribute("href"));
}
for loopuse thefor..eachsyntax.for(WebElement element: elements)