package framework;
import java.io.File;
import com.thoughtworks.selenium.*;
import org.apache.log4j.Logger;
import org.openqa.selenium.server.RemoteControlConfiguration;
import org.openqa.selenium.server.SeleniumServer;
import org.testng.annotations.*;
import org.testng.internal.thread.TestNGThread;
public class BaseTest extends SeleneseTestCase {
private SeleniumServer server;
public static Selenium selenium;
public static Logger logger = Logger.getLogger(BaseTest.class.getName());
@Parameters( { "browser", "hostname", "baseurl","firefox-profile-location" })
@BeforeClass(alwaysRun = true)
public void testUntitled(String browser,
String hostname,
String baseurl,
@Optional("") String firefoxProfileLocation) throws Exception {
try {
if("localhost".equals(hostname)) {
if(!"".equals(firefoxProfileLocation)) {
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.setFirefoxProfileTemplate(new File(firefoxProfileLocation));
server = new SeleniumServer(false, config);
}
else {
server = new SeleniumServer();
}
server.start();
}
} catch (Exception t) {
logger.error("Unable to start Selenium server", t);
fail("Unable to start Selenium server: " + t.getMessage());
}
int port=4444;
selenium = new DefaultSelenium(hostname, port, browser, baseurl);
selenium.start();
}
@AfterClass(alwaysRun = true)
public void closeBrowserAfterEachClass() {
if (selenium != null) {
selenium.close();
selenium.stop();
}
}
}
No comments:
Post a Comment