Friday, May 9, 2014

How to get the test of 1st five news in Yahoo.com

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 YahooGet {
    public static void main(String[] args) {
        WebDriver driver = new FirefoxDriver();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://in.yahoo.com/?p=us");
        List<WebElement> link = driver.findElements(By.xpath("//div[contains(@class,'footer-section')]//li//a"));
        for(WebElement ele: link){
            System.out.println(ele.getText());
        }
    }
}

No comments:

Post a Comment