mirror of
https://repository.entgra.net/community/product-iots.git
synced 2025-09-16 23:32:19 +00:00
Code cleanup and refactoring
This commit is contained in:
parent
ead5b6e2bb
commit
a1b94d5415
@ -32,9 +32,9 @@ import java.io.IOException;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DevicesPage {
|
public class DevicesPage {
|
||||||
|
Log log = LogFactory.getLog(DevicesPage.class);
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
private UIElementMapper uiElementMapper;
|
private UIElementMapper uiElementMapper;
|
||||||
Log log = LogFactory.getLog(DevicesPage.class);
|
|
||||||
|
|
||||||
public DevicesPage(WebDriver driver) throws IOException {
|
public DevicesPage(WebDriver driver) throws IOException {
|
||||||
|
|
||||||
@ -60,24 +60,26 @@ public class DevicesPage {
|
|||||||
|
|
||||||
public ConnectedCupDeviceViewPage viewDevice(String deviceName) throws IOException {
|
public ConnectedCupDeviceViewPage viewDevice(String deviceName) throws IOException {
|
||||||
WebElement deviceTable = driver.findElement(By.xpath(uiElementMapper.getElement("iot.devices.table.xpath")));
|
WebElement deviceTable = driver.findElement(By.xpath(uiElementMapper.getElement("iot.devices.table.xpath")));
|
||||||
List<WebElement> data = deviceTable.findElements(By.cssSelector("a"));
|
List<WebElement> data = deviceTable.findElements(By.cssSelector("a"));
|
||||||
for (WebElement e : data) {
|
for (WebElement e : data) {
|
||||||
String s = getLink(e, "/device/connectedcup?id=");
|
String s = getLink(e, "/device/connectedcup?id=");
|
||||||
if (s != null) {
|
if (s != null) {
|
||||||
driver.get(s);
|
driver.get(s);
|
||||||
return new ConnectedCupDeviceViewPage(driver, deviceName);
|
return new ConnectedCupDeviceViewPage(driver, deviceName);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLink(WebElement element, String lookupText) {
|
|
||||||
String link = element.getAttribute("href");
|
|
||||||
log.info("Link -----------------------> " + link);
|
|
||||||
if (link.contains(lookupText)) {
|
|
||||||
log.info("returned ----------------->>>> " + link);
|
|
||||||
return link;
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getLink(WebElement element, String... lookupText) {
|
||||||
|
String link = element.getAttribute("href");
|
||||||
|
log.info("Link -----------------------> " + link);
|
||||||
|
boolean check = true;
|
||||||
|
for (String s : lookupText) {
|
||||||
|
if (!link.contains(s)) {
|
||||||
|
check = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return check ? link : null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,6 @@ import org.wso2.iot.integration.ui.pages.uesr.UserListingPage;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents the Admin Dashboard of the IOT server.
|
* This class represents the Admin Dashboard of the IOT server.
|
||||||
* Server dashboard has following sections and functions.
|
* Server dashboard has following sections and functions.
|
||||||
@ -69,7 +68,7 @@ public class IOTAdminDashboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LoginPage logout() throws IOException {
|
public LoginPage logout() throws IOException {
|
||||||
driver.findElement(By.xpath("/html/body/header/div/div[2]/a/span[1]")).click();
|
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click();
|
||||||
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
|
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
|
||||||
logout.click();
|
logout.click();
|
||||||
return new LoginPage(driver);
|
return new LoginPage(driver);
|
||||||
|
|||||||
@ -53,7 +53,10 @@ public class IOTHomePage {
|
|||||||
return name.contains(uiElementMapper.getElement("iot.user.login.username"));
|
return name.contains(uiElementMapper.getElement("iot.user.login.username"));
|
||||||
}
|
}
|
||||||
|
|
||||||
//To logout
|
|
||||||
|
/**
|
||||||
|
* Perform the logout action.
|
||||||
|
* */
|
||||||
public LoginPage logout() throws IOException {
|
public LoginPage logout() throws IOException {
|
||||||
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click();
|
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click();
|
||||||
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
|
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
|
||||||
|
|||||||
@ -40,6 +40,9 @@ public class LoginPage {
|
|||||||
private static final Log log = LogFactory.getLog(LoginPage.class);
|
private static final Log log = LogFactory.getLog(LoginPage.class);
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
private UIElementMapper uiElementMapper;
|
private UIElementMapper uiElementMapper;
|
||||||
|
private WebElement userNameField;
|
||||||
|
private WebElement passwordField;
|
||||||
|
private WebElement loginButton;
|
||||||
|
|
||||||
public LoginPage(WebDriver driver) throws IOException {
|
public LoginPage(WebDriver driver) throws IOException {
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
@ -49,6 +52,11 @@ public class LoginPage {
|
|||||||
if (!webDriverWait.until(ExpectedConditions.titleContains("Login | IoT Server"))) {
|
if (!webDriverWait.until(ExpectedConditions.titleContains("Login | IoT Server"))) {
|
||||||
throw new IllegalStateException("This is not the Login page");
|
throw new IllegalStateException("This is not the Login page");
|
||||||
}
|
}
|
||||||
|
userNameField = driver.findElement(By.xpath(
|
||||||
|
uiElementMapper.getElement("iot.user.login.input.username.xpath")));
|
||||||
|
passwordField = driver.findElement(By.xpath(
|
||||||
|
uiElementMapper.getElement("iot.user.login.input.password.xpath")));
|
||||||
|
loginButton = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.button.xpath")));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,13 +68,9 @@ public class LoginPage {
|
|||||||
*/
|
*/
|
||||||
public IOTHomePage loginAsUser(String username, String password) throws IOException {
|
public IOTHomePage loginAsUser(String username, String password) throws IOException {
|
||||||
log.info("Login as " + username);
|
log.info("Login as " + username);
|
||||||
WebElement userNameField = driver.findElement(By.xpath(
|
|
||||||
uiElementMapper.getElement("iot.user.login.input.username.xpath")));
|
|
||||||
WebElement passwordField = driver.findElement(By.xpath(
|
|
||||||
uiElementMapper.getElement("iot.user.login.input.password.xpath")));
|
|
||||||
userNameField.sendKeys(username);
|
userNameField.sendKeys(username);
|
||||||
passwordField.sendKeys(password);
|
passwordField.sendKeys(password);
|
||||||
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.button.xpath"))).click();
|
loginButton.click();
|
||||||
return new IOTHomePage(driver);
|
return new IOTHomePage(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,13 +83,9 @@ public class LoginPage {
|
|||||||
*/
|
*/
|
||||||
public IOTAdminDashboard loginAsAdmin(String username, String password) throws IOException {
|
public IOTAdminDashboard loginAsAdmin(String username, String password) throws IOException {
|
||||||
log.info("Login as " + username);
|
log.info("Login as " + username);
|
||||||
WebElement userNameField = driver.findElement(By.xpath(
|
|
||||||
uiElementMapper.getElement("iot.user.login.input.username.xpath")));
|
|
||||||
WebElement passwordField = driver.findElement(By.xpath(
|
|
||||||
uiElementMapper.getElement("iot.user.login.input.password.xpath")));
|
|
||||||
userNameField.sendKeys(username);
|
userNameField.sendKeys(username);
|
||||||
passwordField.sendKeys(password);
|
passwordField.sendKeys(password);
|
||||||
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.button.xpath"))).click();
|
loginButton.click();
|
||||||
return new IOTAdminDashboard(driver);
|
return new IOTAdminDashboard(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,4 +100,17 @@ public class LoginPage {
|
|||||||
registerLink.click();
|
registerLink.click();
|
||||||
return new NewUserRegisterPage(driver);
|
return new NewUserRegisterPage(driver);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void validateForm(String username, String password) {
|
||||||
|
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
|
||||||
|
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(
|
||||||
|
uiElementMapper.getElement("iot.user.login.input.username.xpath"))));
|
||||||
|
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(
|
||||||
|
uiElementMapper.getElement("iot.user.login.input.password.xpath"))));
|
||||||
|
userNameField.clear();
|
||||||
|
passwordField.clear();
|
||||||
|
userNameField.sendKeys(username);
|
||||||
|
passwordField.sendKeys(password);
|
||||||
|
loginButton.click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -153,9 +153,22 @@ iot.sample.orderCoffee.xpath=//*[@id="order-cup"]
|
|||||||
iot.sample.coffee.level.xpath=//*[@id="amount_coffee"]
|
iot.sample.coffee.level.xpath=//*[@id="amount_coffee"]
|
||||||
iot.sample.temperature.xpath=//*[@id="amount_temp"]
|
iot.sample.temperature.xpath=//*[@id="amount_temp"]
|
||||||
|
|
||||||
|
iot.sample.analytics.link.xpath=//*[@id="device_statistics"]/a
|
||||||
|
|
||||||
|
iot.sample.coffeelevel.graph.path=//*[@id="chart-Coffee Level"]/svg/path[1]
|
||||||
|
iot.sample.temperature.graph.path=//*[@id="chart-Temperature"]/svg/path[1]
|
||||||
|
|
||||||
|
|
||||||
iot.try.devices.div.classname=//div[@class='try-device-container']
|
iot.try.devices.div.classname=//div[@class='try-device-container']
|
||||||
iot.try.device.text.xpath=//p[contains(@class,'try-device-text')]
|
iot.try.device.text.xpath=//p[contains(@class,'try-device-text')]
|
||||||
|
|
||||||
|
|
||||||
|
#------------------ Graphs (Device View) -------------------------------------------------------------------------------
|
||||||
|
iot.stats.graph.container.xpath=//*[@id="div-chart"]
|
||||||
|
iot.stat.graph.wrapper.xpath=//*[contains(@class, "chartWrapper")]
|
||||||
|
iot.stat.graph.xAxis.xpath=//*[contains(@class, "custom_x_axis")]
|
||||||
|
iot.stat.graph.class.name=custom_rickshaw_graph rickshaw_graph
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------------------------------------------------
|
||||||
#iot.user.delete.button=//*[@id="inosh"]/td[5]/a[3]
|
#iot.user.delete.button=//*[@id="inosh"]/td[5]/a[3]
|
||||||
#iot.user.delete.button.confirm=remove-user-yes-link
|
#iot.user.delete.button.confirm=remove-user-yes-link
|
||||||
|
|||||||
@ -27,6 +27,26 @@ public class Constants {
|
|||||||
public static final String IOT_DEVICES_URL = "/devicemgt/devices";
|
public static final String IOT_DEVICES_URL = "/devicemgt/devices";
|
||||||
public static final String IOT_CONNECTED_CUP_NAME = "testDevice";
|
public static final String IOT_CONNECTED_CUP_NAME = "testDevice";
|
||||||
|
|
||||||
|
public static final int IOT_RESTART_THREAD_TIMEOUT = 30;
|
||||||
|
|
||||||
|
public static final String IOT_CONNECTED_CUP_LEVEl = "34";
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE = "53";
|
||||||
|
|
||||||
|
public static final String IOT_GRAPH_X_AXIS = "x";
|
||||||
|
public static final String IOT_GRAPH_Y_AXIS = "y";
|
||||||
|
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE_ID = "Temperature";
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE_LEGEND = "Temperature";
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE_GRAPH_ID = "temperature";
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE_Y_AXIS = "Temperature";
|
||||||
|
public static final String IOT_CONNECTED_CUP_TEMPERATURE_X_AXIS = "time";
|
||||||
|
|
||||||
|
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_ID = "Coffee Level";
|
||||||
|
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_LEGEND = "Coffee Level";
|
||||||
|
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_GRAPH_ID = "coffeelevel";
|
||||||
|
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_Y_AXIS = "Coffeelevel";
|
||||||
|
public static final String IOT_CONNECTED_CUP_COFFEE_LEVEL_X_AXIS = "time";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,11 @@ import org.wso2.carbon.automation.extensions.selenium.BrowserManager;
|
|||||||
import org.wso2.carbon.iot.integration.web.ui.test.Constants;
|
import org.wso2.carbon.iot.integration.web.ui.test.Constants;
|
||||||
import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
|
import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
|
||||||
import org.wso2.iot.integration.ui.pages.UIElementMapper;
|
import org.wso2.iot.integration.ui.pages.UIElementMapper;
|
||||||
|
import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard;
|
||||||
|
import org.wso2.iot.integration.ui.pages.login.LoginPage;
|
||||||
|
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +42,7 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper;
|
|||||||
* 2. Incorrect username or password
|
* 2. Incorrect username or password
|
||||||
* 3. short password
|
* 3. short password
|
||||||
*/
|
*/
|
||||||
public class LoginFailTest extends IOTIntegrationUIBaseTestCase {
|
public class LoginFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
||||||
|
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
private UIElementMapper uiElementMapper;
|
private UIElementMapper uiElementMapper;
|
||||||
@ -57,53 +62,66 @@ public class LoginFailTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
public void emptyLoginFormTest() throws Exception {
|
public void emptyLoginFormTest() throws Exception {
|
||||||
userNameField.sendKeys("");
|
userNameField.sendKeys("");
|
||||||
passwordField.sendKeys("");
|
passwordField.sendKeys("");
|
||||||
|
|
||||||
loginButton.click();
|
loginButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.username.error"))).
|
WebElement alertUserName = driver.findElement(By.id(
|
||||||
getText(), "Please enter a username");
|
uiElementMapper.getElement("iot.user.login.username.error")));
|
||||||
Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))).
|
WebElement alertPassword = driver.findElement(By.id(
|
||||||
getText(), "Please provide a password");
|
uiElementMapper.getElement("iot.user.login.password.error")));
|
||||||
|
|
||||||
|
if (!alertUserName.isDisplayed()) Assert.assertTrue(false, "Alert for user name is not present.");
|
||||||
|
if (!alertPassword.isDisplayed()) Assert.assertTrue(false, "Alert for password is not present.");
|
||||||
|
|
||||||
|
Assert.assertEquals(alertUserName.getText(), "Please enter a username");
|
||||||
|
Assert.assertEquals(alertPassword.getText(), "Please provide a password");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for incorrect username")
|
@Test(description = "Test for incorrect username")
|
||||||
public void incorrectUserNameTest() throws Exception {
|
public void incorrectUserNameTest() throws Exception {
|
||||||
clearForm();
|
clearForm();
|
||||||
|
|
||||||
userNameField.sendKeys("admin1");
|
userNameField.sendKeys("admin1");
|
||||||
passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
|
passwordField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
|
||||||
|
|
||||||
loginButton.click();
|
loginButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))).
|
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
|
||||||
getText(), "Incorrect username or password.!");
|
if (alert.isDisplayed()) {
|
||||||
|
Assert.assertEquals(alert.getText(), "Incorrect username or password.!");
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue(false, "Alert is not present.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for incorrect password")
|
@Test(description = "Test for incorrect password")
|
||||||
public void incorrectPasswordTest() throws Exception {
|
public void incorrectPasswordTest() throws Exception {
|
||||||
clearForm();
|
clearForm();
|
||||||
|
|
||||||
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
|
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getPassword());
|
||||||
passwordField.sendKeys("admnn");
|
passwordField.sendKeys("admnn");
|
||||||
|
|
||||||
loginButton.click();
|
loginButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath"))).
|
WebElement alert = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.login.incorrect.xpath")));
|
||||||
getText(), "Incorrect username or password.!");
|
if (alert.isDisplayed()) {
|
||||||
|
Assert.assertEquals(alert.getText(), "Incorrect username or password.!");
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue(false, "Alert is not present.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test(description = "Test for short password")
|
@Test(description = "Test for short password")
|
||||||
public void shortPasswordTest() throws Exception {
|
public void shortPasswordTest() throws Exception {
|
||||||
clearForm();
|
clearForm();
|
||||||
|
|
||||||
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName());
|
userNameField.sendKeys(automationContext.getSuperTenant().getTenantAdmin().getUserName());
|
||||||
passwordField.sendKeys("ad");
|
passwordField.sendKeys("ad");
|
||||||
|
|
||||||
loginButton.click();
|
loginButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error"))).
|
WebElement alert = driver.findElement(By.id(uiElementMapper.getElement("iot.user.login.password.error")));
|
||||||
getText(), "Your password must be at least 3 characters long");
|
if (alert.isDisplayed()) {
|
||||||
|
Assert.assertEquals(alert.getText(), "Your password must be at least 3 characters long");
|
||||||
|
} else {
|
||||||
|
Assert.assertTrue(false, "Alert is not present.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearForm() throws Exception {
|
public void clearForm() throws Exception {
|
||||||
@ -35,7 +35,7 @@ import javax.xml.xpath.XPathExpressionException;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test cases for
|
* Class contains test cases for Add user form validation.
|
||||||
* 1. Empty form submission
|
* 1. Empty form submission
|
||||||
* 2. Short user name
|
* 2. Short user name
|
||||||
* 3. Empty First Name
|
* 3. Empty First Name
|
||||||
@ -47,7 +47,6 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
private WebDriver driver;
|
private WebDriver driver;
|
||||||
private UIElementMapper uiElementMapper;
|
private UIElementMapper uiElementMapper;
|
||||||
|
|
||||||
private WebElement firstNameField;
|
private WebElement firstNameField;
|
||||||
private WebElement lastNameField;
|
private WebElement lastNameField;
|
||||||
private WebElement emailField;
|
private WebElement emailField;
|
||||||
@ -71,7 +70,7 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for empty form submission")
|
@Test(description = "Test for empty form submission")
|
||||||
public void emptyFormTest(){
|
public void emptyFormTest() {
|
||||||
clearForm();
|
clearForm();
|
||||||
|
|
||||||
firstNameField.sendKeys("");
|
firstNameField.sendKeys("");
|
||||||
@ -81,9 +80,14 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
"Username is a required field. It cannot be empty.");
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for empty form not is displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Username is a required field. It cannot be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for short user name")
|
@Test(description = "Test for short user name")
|
||||||
@ -97,9 +101,14 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
"Username must be between 3 and 30 characters long.");
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for short user name is not displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Username must be between 3 and 30 characters long.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for empty first name")
|
@Test(description = "Test for empty first name")
|
||||||
@ -113,9 +122,14 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
"Firstname is a required field. It cannot be empty.");
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for First name is not displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Firstname is a required field. It cannot be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for empty last name")
|
@Test(description = "Test for empty last name")
|
||||||
@ -128,9 +142,15 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
userNameField.sendKeys("user1");
|
userNameField.sendKeys("user1");
|
||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
"Lastname is a required field. It cannot be empty.");
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for Last name is not displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Lastname is a required field. It cannot be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for empty email name")
|
@Test(description = "Test for empty email name")
|
||||||
@ -144,9 +164,14 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
"Email is a required field. It cannot be empty.");
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for E-mail is not displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Email is a required field. It cannot be empty.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(description = "Test for incorrect email")
|
@Test(description = "Test for incorrect email")
|
||||||
@ -160,9 +185,14 @@ public class AddUserFormValidationTest extends IOTIntegrationUIBaseTestCase {
|
|||||||
|
|
||||||
addUserButton.click();
|
addUserButton.click();
|
||||||
|
|
||||||
Assert.assertEquals(driver.findElement(By.xpath(
|
WebElement alert = driver.findElement(By.xpath(
|
||||||
uiElementMapper.getElement("iot.admin.addUser.formError.xpath"))).getText(),
|
uiElementMapper.getElement("iot.admin.addUser.formError.xpath")));
|
||||||
"Provided email is invalid. Please check.");
|
|
||||||
|
if (!alert.isDisplayed()) {
|
||||||
|
Assert.assertTrue(false, "Alert for incorrect E-mail is not displayed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.assertEquals(alert.getText(), "Provided email is invalid. Please check.");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearForm() {
|
private void clearForm() {
|
||||||
|
|||||||
@ -26,18 +26,19 @@
|
|||||||
</packages>
|
</packages>
|
||||||
|
|
||||||
<classes>
|
<classes>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.login.LoginTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.login.LoginFormValidationTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.user.NewUserRegistrationTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.login.LoginTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.user.RegistrationFormValidationTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.user.RegistrationFormValidationTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.login.LoginFailTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.user.NewUserRegistrationTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.group.DeviceGroupTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.group.DeviceGroupTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.group.DeviceGroupFailTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.group.DeviceGroupFailTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.user.AdminFunctionsTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.user.AddUserFormValidationTest"/>
|
||||||
<!--<class name="org.wso2.carbon.iot.integration.web.ui.test.user.AddUserFormValidationTest"/>-->
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.user.AdminFunctionsTest"/>
|
||||||
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleInstallationTest"/>
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleInstallationTest"/>
|
||||||
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleInstallationVerification"/>
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleInstallationVerification"/>
|
||||||
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleEnrollmentTest"/>
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleEnrollmentTest"/>
|
||||||
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleEnrolmentVerificationTest"/>
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleEnrolmentVerificationTest"/>
|
||||||
|
<class name="org.wso2.carbon.iot.integration.web.ui.test.samples.SampleFunctionalityTest"/>
|
||||||
</classes>
|
</classes>
|
||||||
|
|
||||||
</test>
|
</test>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user