Showing posts with label TestNG. Show all posts
Showing posts with label TestNG. Show all posts

Sunday, January 2, 2011

Code to start Selenium Server in TestNG

This is the basic structure of TestNG class

package file;

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

import com.thoughtworks.selenium.*;
import org.openqa.selenium.server.SeleniumServer;

public class NewTest {
private SeleniumServer seleniumServer;
private Selenium selenium = new DefaultSelenium( "localhost",4444,
"*chrome","http://");

@Test
public void f() {
}

@BeforeTest
public void beforeTest() throws Exception {
seleniumServer = new SeleniumServer();
seleniumServer.start();
selenium.start();
}

@AfterTest
public void afterTest() {
selenium.stop();
seleniumServer.stop();
}

}