I am using WebDriver to do the automatic web test. Different web driver instance can start different browser to do the test.
For example, this code will start firefox.
WebDriver driver = new FirefoxDriver();
This code will start internet explore to do the test.
WebDriver driver = new InternetExplorerDriver();
I want to run my test on both firefox and IE to make sure my java script works on both. The test is the same, the only difference is to use different driver instance. I need run one test twice, one with firefox driver, the other one with ie driver. Junit parameterized is exact for that purpose.
I put this code in the abstract super class of all my web driver tests.
private static WebDriver firefoxDriver = new FirefoxDriver();
private static WebDriver internetExplorerDriver = new InternetExplorerDriver();
@Parameters
public static Collection
My web driver test also need provide a constructor using WebDriver as argument.
public
this.driver = driver;
}
In the example above, junit will pass “firefoxDriver” to the test and run all the tests and then pass “internetExploreDriver” and test again.
No comments:
Post a Comment