Tuesday, June 18, 2013

Test Case using TestNG

package Pract;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.AfterClass;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
public class FirstTNG {

public SeleniumServer seleniumServer;//Create a variable
public Selenium selenium;//Create a variable

@BeforeClass
public void beforeClass() throws Exception
{
seleniumServer=new SeleniumServer();//Create an object
seleniumServer.start();//start selenium server
selenium=new DefaultSelenium("localhost", 4444, "*firefox", "http://"); //Pass arguments to selenium
selenium.start();//srat selenium server
}
@Test
public void testFirstTNG() throws Exception
{
//open google page
selenium.open("http://www.google.com");
//maximize window
selenium.windowMaximize();
Thread.sleep(5000);
}
@AfterClass
public void afterClass()
{

//stop selenium
selenium.stop();
//stop selenium server
seleniumServer.stop();
}
}

No comments:

Post a Comment