大家好我已经在selenium中编写了多个测试用例,使用WebDriver
以下是我在门户网站上执行此任务的硒代码
Base Selenium Class
public class BaseSeleniumTest extends SeleneseTestBase {
protected static WebDriver driver;
@BeforeSuite
public static void firefoxSetUp() throws MalformedURLException {
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
@AfterSuite
public static void closeFirefox(){
driver.quit();
}
}//End BaseSeleniumTest Class.
登录测试用例
public class LogInTest extends BaseSeleniumTest {
LogInPage page;
public static final String BASE_URL = "http://www.mywebsite.com";
@BeforeMethod
public void beforeMethod() {
page = PageFactory.initElements(driver, LogInPage.class);
page.openPage(BASE_URL);
}
@Test(dataProvider="loginData",groups="loginGroup")
public void logIn(String email,String password) {
page.logInAs(email, password);
}
@DataProvider(name = "loginData")
public Object[][] getData() {
return new Object[][] { { "username", "password" } };
}
}//End of LogInTest Class.
添加群组测试用例
public class AddGroupTest extends BaseSeleniumTest {
AddGroupPage addGroupPage;
@BeforeMethod
public void openAddGroupPage() {
addGroupPage = PageFactory.initElements(driver, AddGroupPage.class);
addGroupPage.openPage();
}
@Test(dataProvider = "getCSVData",dataProviderClass=AddGroupsDataProvider.class,dependsOnGroups={"loginGroup"},groups="addGroup")
public void AddGroup(String groupName,String displayName,String description) {
addGroupPage.addGroup(groupName, displayName, description);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
}//End of AddGroupTest Class.
添加位置测试用例
public class AddLocationTest extends BaseSeleniumTest {
AddLocationPage addLocationPage;
@BeforeMethod
public void openAddLocationPage() {
addLocationPage = PageFactory.initElements(driver, AddLocationPage.class);
addLocationPage.openPage();
}
@Test(dataProvider = "getCSVData", dataProviderClass = AddLocationDataProvider.class, dependsOnGroups = { "loginGroup" }, groups = "addLocation")
public void addLocation(String locationName, String displayName,
String description, String groups) {
addLocationPage.addLocation(locationName, displayName, description,
groups.split(","));
}
}
当我独立运行这个脚本时,它们运行得很好我现在想把这个脚本作为套件来运行,但我不知道从哪里开始。由于依赖于Add Group和Add Group测试用例的Add Location Test案例依赖于Login测试用例。
以下是我的问题
提前致谢...
答案 0 :(得分:1)
您的问题会导致基于意见的答案,通常为off-topic for SO。考虑浏览Software Quality Assurance & Testing Stack Exchange。
我打算试着给你至少一些答案。你应该: