Sunday, April 10, 2011

Standard code for @BeforeTest and @AfterTest in TestNG

@BeforeTest
public void setUp() throws Exception {
SeleniumServer seleniumserver=new SeleniumServer();
seleniumserver.boot();
seleniumserver.start();
setUp("http://www.ge.com/", "*firefox");
selenium.open("/");
selenium.windowMaximize();
selenium.windowFocus();
}

@Test public void testTC_GE_EE() throws Exception {
// your testing code goes here
}


@AfterTest
public void tearDown(){
selenium.close();
selenium.stop();
}

----------------

@BeforeTest
public void setUp() throws Exception {
SeleniumServer seleniumserver=new SeleniumServer();
seleniumserver.boot();
seleniumserver.start();

Integer port = 4444;
String browserString= "*firefox";
String url = "http://www.ge.com";
selenium = new DefaultSelenium("localhost",port,browserString,url) {
public void open(String url) { commandProcessor.doCommand("open", new String[] {url,"true"});};
};
selenium.start();

selenium.setTimeout("120000");
selenium.open("/");
selenium.windowMaximize();
selenium.windowFocus();
}

No comments:

Post a Comment