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