包含测试用例的类
public class SeleniumTestcaseParameterized {
WebDriver driver;
private String userName, password, baseUrl;
public SeleniumTestcaseParameterized(String userName, String password) {
this.userName = userName;
this.password = password;
}
@Before
public void setUp() {
}
@Test
public void testSeleniumTestcaseParameterized() throws Exception {
driver.get(baseUrl + "url");
driver.findElement(By.id("username")).sendKeys(userName);
driver.findElement(By.id("password")).sendKeys(password);
}
@After
public void tearDown() {
driver.quit();
}
在main方法中调用测试用例的类
public class MainClass {
public static void main(String[] args) {
String name =JOptionPane.showInputDialog("Please enter Username");
SeleniumTestcaseParameterized c = new SeleniumTestcaseParameterized(name,name);
junit.textui.TestRunner.run(c.getClass());
}
我无法将参数传递给main的测试用例。