Monday, 3 November 2014

How to create a test using TestNG

How to create a test using TestNG





package com.snapdeal;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;

import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;

public class GogleTest {
    WebDriver driver = new FirefoxDriver();

    @Test
    public void func() {
        driver.findElement(By.name("q")).sendKeys("test");

    }

    @BeforeTest
    public void beforeTest() {

        driver.get("https://www.google.co.in/?gfe_rd=cr&ei=CoBWVMj9A9jBuATG6ICQDw");
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    }

    @AfterTest
    public void afterTest() {
        driver.close();
    }

}

No comments:

Post a Comment