Showing posts with label Extract All Web Link. Show all posts
Showing posts with label Extract All Web Link. Show all posts

Monday, 17 November 2014

How to Extract All Web Link from a website

//How to Extract All Web Link from a website

package com.snapdeal;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
public class ExtrackAllLinks {
public static void main(String[] args) {
// TODO Auto-generated method stub
WebDriver driver = new FirefoxDriver();
driver.get(“http://seleniumguru.in/”);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
List<WebElement> list = driver.findElements(By.tagName(“a”));
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i).getAttribute(“href”));
}
driver.close();
}
}