|
|
@ -19,6 +19,7 @@ package org.wso2.carbon.iot.integration.web.ui.test.user;
|
|
|
|
|
|
|
|
|
|
|
|
import org.openqa.selenium.By;
|
|
|
|
import org.openqa.selenium.By;
|
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
|
import org.openqa.selenium.WebDriver;
|
|
|
|
|
|
|
|
import org.openqa.selenium.WebElement;
|
|
|
|
import org.testng.Assert;
|
|
|
|
import org.testng.Assert;
|
|
|
|
import org.testng.annotations.AfterClass;
|
|
|
|
import org.testng.annotations.AfterClass;
|
|
|
|
import org.testng.annotations.BeforeClass;
|
|
|
|
import org.testng.annotations.BeforeClass;
|
|
|
@ -52,57 +53,88 @@ public class RegistrationFormValidationTest extends IOTIntegrationUIBaseTestCase
|
|
|
|
driver.get(getWebAppURL() + Constants.IOT_USER_REGISTER_URL);
|
|
|
|
driver.get(getWebAppURL() + Constants.IOT_USER_REGISTER_URL);
|
|
|
|
registerPage = new NewUserRegisterPage(driver);
|
|
|
|
registerPage = new NewUserRegisterPage(driver);
|
|
|
|
uiElementMapper = UIElementMapper.getInstance();
|
|
|
|
uiElementMapper = UIElementMapper.getInstance();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Test for submitting an empty registration form")
|
|
|
|
@Test(description = "Test for submitting an empty registration form")
|
|
|
|
public void emptyFormTest() throws IOException {
|
|
|
|
public void emptyFormTest() throws IOException {
|
|
|
|
registerPage.clearForm();
|
|
|
|
registerPage.clearForm();
|
|
|
|
registerPage.validateForm("", "", "", "", "", "");
|
|
|
|
registerPage.validateForm("", "", "", "", "", "");
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
WebElement alertFirstName = driver.findElement(By.id(
|
|
|
|
uiElementMapper.getElement("iot.user.register.firstname.error"))).getText(),
|
|
|
|
uiElementMapper.getElement("iot.user.register.firstname.error")));
|
|
|
|
"Firstname is a required field. This cannot be empty.");
|
|
|
|
WebElement alertLastName = driver.findElement(By.id(
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
uiElementMapper.getElement("iot.user.register.lastname.error")));
|
|
|
|
uiElementMapper.getElement("iot.user.register.lastname.error"))).getText(),
|
|
|
|
WebElement alertEmail = driver.findElement(By.id(
|
|
|
|
"Lastname is a required field. This cannot be empty.");
|
|
|
|
uiElementMapper.getElement("iot.user.register.email.error")));
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
WebElement alertUserName = driver.findElement(By.id(
|
|
|
|
uiElementMapper.getElement("iot.user.register.email.error"))).getText(),
|
|
|
|
uiElementMapper.getElement("iot.user.register.username.error")));
|
|
|
|
"Email is a required field. This cannot be empty.");
|
|
|
|
WebElement alertPassword = driver.findElement(By.id(
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
uiElementMapper.getElement("iot.user.register.password.error")));
|
|
|
|
uiElementMapper.getElement("iot.user.register.username.error"))).getText(),
|
|
|
|
WebElement alertConfPassword = driver.findElement(By.id(
|
|
|
|
"Username is a required field. This cannot be empty.");
|
|
|
|
uiElementMapper.getElement("iot.user.register.confirmPassword.error")));
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
|
|
|
|
uiElementMapper.getElement("iot.user.register.password.error"))).getText(),
|
|
|
|
if (!alertFirstName.isDisplayed()) {
|
|
|
|
"Please enter a user login password");
|
|
|
|
Assert.assertTrue(false, "Alert for first name is not displayed");
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
}
|
|
|
|
uiElementMapper.getElement("iot.user.register.confirmPassword.error"))).getText(),
|
|
|
|
if (!alertLastName.isDisplayed()) {
|
|
|
|
"Please enter a user login password");
|
|
|
|
Assert.assertTrue(false, "Alert for last name is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alertEmail.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for email is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alertUserName.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for user name is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alertPassword.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for password is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!alertConfPassword.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for confirm password is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(alertFirstName.getText(), "Firstname is a required field. This cannot be empty.");
|
|
|
|
|
|
|
|
Assert.assertEquals(alertLastName.getText(), "Lastname is a required field. This cannot be empty.");
|
|
|
|
|
|
|
|
Assert.assertEquals(alertEmail.getText(), "Email is a required field. This cannot be empty.");
|
|
|
|
|
|
|
|
Assert.assertEquals(alertUserName.getText(), "Username is a required field. This cannot be empty.");
|
|
|
|
|
|
|
|
Assert.assertEquals(alertPassword.getText(), "Please enter a user login password");
|
|
|
|
|
|
|
|
Assert.assertEquals(alertConfPassword.getText(), "Please enter a user login password");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Test for non matching passwords")
|
|
|
|
@Test(description = "Test for non matching passwords")
|
|
|
|
public void nonMatchingPasswordTest() {
|
|
|
|
public void nonMatchingPasswordTest() {
|
|
|
|
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "password", "Password");
|
|
|
|
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "password", "Password");
|
|
|
|
|
|
|
|
WebElement alertConfPassword = driver.findElement(By.id(
|
|
|
|
|
|
|
|
uiElementMapper.getElement("iot.user.register.confirmPassword.error")));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!alertConfPassword.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for confirm password is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
Assert.assertEquals(alertConfPassword.getText(), "Please enter the same password as above");
|
|
|
|
uiElementMapper.getElement("iot.user.register.confirmPassword.error"))).getText(),
|
|
|
|
|
|
|
|
"Please enter the same password as above");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Test for email")
|
|
|
|
@Test(description = "Test for email")
|
|
|
|
public void incorrectEmailTest() {
|
|
|
|
public void incorrectEmailTest() {
|
|
|
|
registerPage.validateForm("user", "user", "user123", "user1", "password", "password");
|
|
|
|
registerPage.validateForm("user", "user", "user123", "user1", "password", "password");
|
|
|
|
|
|
|
|
WebElement alertEmail = driver.findElement(By.id(
|
|
|
|
|
|
|
|
uiElementMapper.getElement("iot.user.register.email.error")));
|
|
|
|
|
|
|
|
if (!alertEmail.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for email is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
Assert.assertEquals(alertEmail.getText(), "Email is not valid. Please enter a correct email address.");
|
|
|
|
uiElementMapper.getElement("iot.user.register.email.error"))).getText(),
|
|
|
|
|
|
|
|
"Email is not valid. Please enter a correct email address.");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Test(description = "Test for password length")
|
|
|
|
@Test(description = "Test for password length")
|
|
|
|
public void passwordLengthTest() {
|
|
|
|
public void passwordLengthTest() {
|
|
|
|
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "pass", "pass");
|
|
|
|
registerPage.validateForm("user", "user", "user@wso2.com", "user1", "pass", "pass");
|
|
|
|
Assert.assertEquals(driver.findElement(By.id(
|
|
|
|
WebElement alertPassword = driver.findElement(By.id(
|
|
|
|
uiElementMapper.getElement("iot.user.register.password.error"))).getText(),
|
|
|
|
uiElementMapper.getElement("iot.user.register.password.error")));
|
|
|
|
"Password should be between 5 and 30 characters.");
|
|
|
|
if (!alertPassword.isDisplayed()) {
|
|
|
|
|
|
|
|
Assert.assertTrue(false, "Alert for password is not displayed");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Assert.assertEquals(alertPassword.getText(), "Password should be between 5 and 30 characters.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@AfterClass(alwaysRun = true)
|
|
|
|
@AfterClass(alwaysRun = true)
|
|
|
|