I have this code for testing a site with selenium webdriver. There are four @Test
methods, and a @DataProvider
with three values. So, in total twelve tests get run.
public class SomeTest {
WebDriver driver;
@DataProvider(name = "URLs")
public Object[][] createData1() {
return new Object[][] {
{"url 1"},
{"url 2"},
{"url 3"}};
}
@BeforeMethod
//right now I'm just setting up weddriver for chrome, but
//I'll need to run this test for firefox, chrome, and IE
public void setUpWebDriver(){
driver = WebDrivers.getChromeDriver();
}
@AfterMethod
public void closeWebDriver(){
driver.quit();
}
//test methods below
@Test(dataProvider = "URLs")
public void test1(String url){
//test 1 with url
}
@Test(dataProvider = "URLs")
public void test2(String url){
//test 2 with url
}
@Test(dataProvider = "URLs")
public void test3(String url){
//test 3 with url
}
@Test(dataProvider = "URLs")
public void test4(String url){
//test 4 with url
}
}
Right now, these tests are running under Chrome. But I also want to repeat all of these tests, with all of the data provider variations, on Firefox and Internet explorer. How can I get the entire class of tests to repeat for these other webdrivers? It's almost like I need a @DataProvider
for the entire class (for the beforemethod).