Reputation: 21
my TestCases (TestClasses) like TestLogIn, TestLogOut, TestSendEmail, TestDeleteEmail etc are starting everytime new ChromeDriver instance .. How can I run multiple tests with one WebDriver instance? Can anyone provide me some example?
My structure in java:
GenericClass.java:
public class GenericClass extends TestCase
//some code
TestLogin.java:
public class TestLogin extends GenericClass
//code
Upvotes: 2
Views: 2709
Reputation: 131
My idea for solving this was to make the WebDriver static.
public class ProjectTests {
static WebDriver driver;
@BeforeClass
public static void setStuff()
{
driver = new FirefoxDriver();
}
@Test
public void testOne(){}
Then, you can pass the driver instance to each of the test methods. The tests will be performed in the same instance of the WebDriver. Maybe it's not the most elegant method of doing it, but for me it works.
Upvotes: 2