QAF - 想在每次测试时打开和关闭浏览器
QAF - wanted to open and close the browser with each test
我在 UI 自动化框架中使用 QAF 开源 Java 库,并希望在每次测试时打开和关闭浏览器。但是,不能用下面的代码做到这一点,因此由 testSuccessfulLogin() 打开的浏览器保持打开状态,因此 testFailedLogin() 失败。
public class LoginTestCase extends WebDriverTestCase {
@Test(testName="SuccessfulLogin", description="Successful Login with valid username and password", groups={"SMOKE"})
public void testSuccessfulLogin() {
LoginPage loginPage = new LoginPage();
loginPage.openPage();
verifyLinkWithTextPresent("Or Sign Up");
loginPage.enterUsername("asdf.asdf");
loginPage.enterPassword("Asdf@1234");
loginPage.clickLogInButton();
verifyLinkWithTextPresent("Dashboard");
verifyLinkWithTextPresent("Logout");
}
@Test(testName="FailedLogin", description="Login with blank username and password", groups={"SMOKE"})
public void testFailedLogin() {
LoginPage loginPage = new LoginPage();
loginPage.openPage();
verifyLinkWithTextPresent("Or Sign Up");
loginPage.enterUsername("");
loginPage.enterPassword("");
loginPage.submitLoginForm();
verifyLinkWithTextPresent("Dashboard");
verifyLinkWithTextPresent("Logout");
}
}
设置selenium.singletone=method
即可实现。在应用程序属性或 xml 配置文件中指定它。参考 list of properties and how to set properties.
我在 UI 自动化框架中使用 QAF 开源 Java 库,并希望在每次测试时打开和关闭浏览器。但是,不能用下面的代码做到这一点,因此由 testSuccessfulLogin() 打开的浏览器保持打开状态,因此 testFailedLogin() 失败。
public class LoginTestCase extends WebDriverTestCase {
@Test(testName="SuccessfulLogin", description="Successful Login with valid username and password", groups={"SMOKE"})
public void testSuccessfulLogin() {
LoginPage loginPage = new LoginPage();
loginPage.openPage();
verifyLinkWithTextPresent("Or Sign Up");
loginPage.enterUsername("asdf.asdf");
loginPage.enterPassword("Asdf@1234");
loginPage.clickLogInButton();
verifyLinkWithTextPresent("Dashboard");
verifyLinkWithTextPresent("Logout");
}
@Test(testName="FailedLogin", description="Login with blank username and password", groups={"SMOKE"})
public void testFailedLogin() {
LoginPage loginPage = new LoginPage();
loginPage.openPage();
verifyLinkWithTextPresent("Or Sign Up");
loginPage.enterUsername("");
loginPage.enterPassword("");
loginPage.submitLoginForm();
verifyLinkWithTextPresent("Dashboard");
verifyLinkWithTextPresent("Logout");
}
}
设置selenium.singletone=method
即可实现。在应用程序属性或 xml 配置文件中指定它。参考 list of properties and how to set properties.