I have general questions about Managing selenium web project, the example is below, my question is how to manage those test cases?(its only 3 for the example, the real number of test cases is more than 1000)
Did create class for sub tests is good, like class for login and all the tests that related to log in is under this class?
Did there is an Conventions for writing test cases and manage them?
Thanks you all.
I create class with tests like:
@Test //Test1
public void logInFaildTest() {
GridTest gridTest = new GridTest();
WebDriver webDriver = gridTest.getWebDriver();
String url = gridTest.getUrl();
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
logIn.login(userName, pass);
WebElement errorMsg = webDriver.findElement(By.className("dijitToasterContent"));
String actual = errorMsg.getAttribute("innerHTML");
String expected="Incorrect user name or password. Please try again.";
assertEquals(expected, actual);
webDriver.close();
}
@Test
public void loginSucsecc()
{
GridTest gridTest = new GridTest();
String url = gridTest.getUrl();
WebDriver webDriver = gridTest.getWebDriver();
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="pass";
logIn.login(userName, pass);
String actual = webDriver.getCurrentUrl();
String expected= url+"#lastmile/";
// webDriver.close();
webDriver.quit();
assertEquals(expected, actual);
}
@Test
public void accountLock()
{
GridTest gridTest = new GridTest();
String url = gridTest.getUrl();
WebDriver webDriver = gridTest.getWebDriver();
LoginPage logIn = new LoginPage(webDriver, url);
String userName = "user";
String pass="wrong";
for(int i=0;i<11;i++){
logIn.login(userName, pass);
logIn.clearFileduNamePass();
}
WebElement msg = webDriver.findElement(By.id("dijit__TemplatedMixin_0")); //block message
String actual = msg.getAttribute("innerHTML");
int splitIndex= actual.indexOf(".<");
actual = actual.substring(0, splitIndex);
String expected= "Your account has been locked";
webDriver.quit();
assertEquals(expected, actual);
}
}