Sunday 7 February 2016

Find total number of time word selenium present in (rameshselenium.blogspot.in)

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 BlogDemo {
    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("http://rameshselenium.blogspot.in/");

        List<WebElement> text = driver.findElements(By.partialLinkText("selenium"));
        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 rameshselenium.blogspot.in is: "
                        + count);

        driver.quit();

    }
}

No comments:

Post a Comment