0

My question : Is there a way, to execute test class in isolation and even with testsuite ? I mean i have a test suite where i have included test class for execution. Now, if i want to run the test class separately, so how should i do that ? Here, both the test classes (Test1, Test2) are dependent on @BeforeClass of Test Suite I have tried up solutions : Use same web driver throughout selenium suite

Code : MySuite Class

@RunWith(Suite.class)
@SuiteClasses(
{
    Test1.class,
    Test2.class,
}
public class MySuite 
{
    static WebDriver driver;

public static WebDriver getWebDriver()
{
    return driver;
}
@BeforeClass
public static void start()throws Exception
{
  System.setProperty("webdriver.chrome.driver", "E:/abc/lib/chromedriver.exe");
  driver = new ChromeDriver();
  driver.get("My URL");
  System.out.println("Before Class");
}

}

Code :

public class Test1{
private WebDriver driver;
public Test1()
{
    driver = MySuite.getWebDriver();
    PageFactory.initElements(driver, this);
}

@Test
public void A()
{
  //
}

Similar is the Test2.class

Community
  • 1
  • 1
user2376425
  • 85
  • 1
  • 3
  • 12
  • What exactly are you trying to do? Use a different instance of WebDriver in each test? – Ittiel Sep 18 '13 at 18:54
  • I just need to know how i should run my test class in isolate manner also. Am able to execute the test suite, but here if i want to execute only one particular class...then how to do that. Here, both the classes are independent of each other – user2376425 Sep 19 '13 at 04:59

0 Answers0