Friday 8 May 2015

Selenium:Validations using asertions using selenium webdriver


import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;

public class Validations {

    public static void main(String[] args) throws InterruptedException {

        WebDriver d = new FirefoxDriver();
        d.manage().window().maximize();
        d.get("https://www.google.co.in/");
        d.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        System.out.println(d.findElement(By.xpath(".//*[@id='hplogo']"))
                .getText());
        String text = d.findElement(By.xpath(".//*[@id='hplogo']")).getText();
        Assert.assertEquals("India", text);
        // Assert.assertTrue(true, text);
        // Assert.assertFalse(false, text);
        System.out.println("hello validations");
        Thread.sleep(6000);
        d.quit();

No comments:

Post a Comment