Thursday 6 June 2013

check if some text exist or not in the page

package abc;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Test;
@Test
public class Sample {
public static void AAA(){
   
        WebDriver driver = new FirefoxDriver();
        driver.get("http://flipkart.com");
        driver.manage().window().maximize();
        String Pagetitle = driver.getTitle();
        System.out.println(Pagetitle);
        driver.findElement(By.xpath(".//*[@id='flyout-menu']/ul/li/div[1]/a")).click();
        boolean xxx = driver.findElements( By.xpath(".//*[@id='fk-header-tab-mobile']/div[1]/div/div[1]/a")).size() != 0;
        if (xxx==true){
        System.out.println("Pass");
        }
        else {
        System.out.println("Fail");
        }
        }
        }

No comments:

Post a Comment