Sunday, 7 February 2016

Find total number of time word ADP in adp website(www.adp.com)

package selenium.basics;

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 AdpDemo {
    public static void main(String[] args) {

        int count = 0;

        WebDriver driver = new FirefoxDriver();

        driver.manage().window().maximize();

        driver.manage().deleteAllCookies();

        driver.manage().timeouts().implicitlyWait(45, TimeUnit.SECONDS);

        driver.get("www.adp.com/");

        List<WebElement> text = driver.findElements(By.xpath("//*[text()='ADP']"));
        System.out.println(text.size());

        for (WebElement webElement : text) {
            System.out.println(webElement.getText());
            count++;
        }
        System.out
                .println("the number of times word selenium present in www.adp.com is: "
                        + count);

        driver.quit();

    }
}

No comments:

Post a Comment