Anand,
If it's of any help to you, here's what I did in setting up the
@BeforeSuite & @AfterSuite for Selenium testing.
I defined a Base Test class(see code below), which contains the
@BeforeSuite & @AfterSuite methods.
The @BeforeSuite starts the Selenium RC driver instance, sets the
speed and logs in. The @AfterSuite logs out & shuts down.
Other test classes then extend this Base Test class. This way I only
need to refer to the Test classes in the xml file.
public class OAMBaseTestClass {
protected static OAMMainPage myOAMMainPage;
protected static SeleniumHelper selenium;
@BeforeSuite (alwaysRun = true)
@Parameters({"selenium.host","selenium.port","selenium.browser","selenium.url",
"selenium.speed", "username","password"})
public void Setup(String selHost, String selPort, String
selBrowser,String selURL, String selSpeed, String username, String
password) {
// Start the Selenium RC instance
selenium = new SuiteUtils().getSeleniumHelperInstance(selHost,
selPort, selBrowser, selURL);
selenium.setSpeed(selSpeed);
OAMLoginPage myOAMLoginPage = new OAMLoginPage(selenium);
OAMAppSelectorPage myOAMAppSelectorPage = new
OAMAppSelectorPage(selenium);
System.out.print("\n$$$Waiting for Login Page\n");
while (!myOAMLoginPage.isLoginPageLoaded()){
System.out.print(".");
}
if (myOAMLoginPage.functionLogin(username, password)){
System.out.print("\n$$$Login was successful\n");
myOAMAppSelectorPage.doClickOAMLink();
System.out.print("\n$$$OAM Link clicked...\n");
}
else {
selenium.takeScreenShot("LOGIN Failed");
new SuiteUtils().endSeleniumInstance(selenium);
fail("Failed to login");
}
}
@AfterSuite(alwaysRun = true)
public void SuiteTeardown (){
myOAMMainPage.doLogout();
new SuiteUtils().endSeleniumInstance(selenium);