Ok - I tried the @Factory(Documentation #Section 5.7 - Factories)
annotation and here are the results.
1. Two browser sessions are created by WebDriver.
2. First one open the desired page and nothing happens.
3. Second one go through all the test cases.
Here is sample of my class
public class Wordpress {
static WebDriver driver;
static WebElement element;
Page page = new Page(driver);
private int m_numberOfTimes;
public Wordpress(int numberOfTimes) {
m_numberOfTimes = numberOfTimes;
}
@BeforeClass(alwaysRun = true)
public void setupBeforeSuite(ITestContext context) {
for (int i = 0; i < m_numberOfTimes; i++) {
String getUrl =
context.getCurrentXmlTest().getParameter("webdriver.url");
driver = new FirefoxDriver();
driver.get(getUrl);
}
}
@AfterClass(alwaysRun = true)
public void setupAfterSuite() {
driver.quit();
}
@Test(description="Maximize Browser Window")
public void MaximizeBrowser(){
//some code
}
@Test(description="Verfiy If We Are On Home Page", dependsOnMethods =
{ "MaximizeBrowser" })
public void homePage(){
//some code
}
@Test(description="Goto Login Page",dependsOnMethods =
{ "homePage" })
public void loginPage(){
//some code
}
@Test(description="Enter Valid Login Details", dependsOnMethods =
{ "loginPage" })
public void enterlogindetails(ITestContext context) {
//some code
}
======================== And This Is Another Class
================================================
public class WebTestFactory {
@Factory
public Object[] createInstances() {
Object[] result = new Object[2];
for (int i = 0; i < 2; i++) {
result[i] = new Wordpress(i * 2);
}
return result;
}
}
===============================================================================================
On Sep 15, 10:39 pm, Cédric Beust ♔ <
ced...@beust.com> wrote:
> Did you look it up in the documentation? Anything that's not clear?
>
> --
> Cédric
>