Added javadoc comments

application-manager-new
Menaka Madushanka 9 years ago
parent ef9c3dfe70
commit 4cf1d77311

@ -24,6 +24,9 @@ import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
/**
* This class contains the constants and common methods used in pages.
*/
public class UIUtils {
public static long webDriverTimeOut = 10;
public static long webDriverTime = 60;

@ -31,6 +31,14 @@ import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceViewPage;
import java.io.IOException;
import java.util.List;
/**
* Class to represent the IOT devices page. In this page, all the enrolled devices are listed.
* User can perform following functions on the enrolled devices.
* 1. View the device.
* 2. View device analytics.
* 3. Edit the device.
* 4. Delete the device.
*/
public class DevicesPage {
Log log = LogFactory.getLog(DevicesPage.class);
private WebDriver driver;
@ -46,6 +54,11 @@ public class DevicesPage {
}
}
/**
* This method checks whether the given device is enrolled and visible in the UI of the IOT server.
* @param name : The name of the device to be checked.
* @return : True if the device is enrolled and visible. False otherwise.
*/
public boolean isDeviceEnrolled(String name) {
List<WebElement> deviceNames = driver.findElements(By.tagName("h4"));
if (!deviceNames.isEmpty()) {
@ -58,6 +71,12 @@ public class DevicesPage {
return false;
}
/**
* This method performs the navigation to the Device view of the given device.
* Here the navigation happens to the Connected cup device.
* @param deviceName : Name of the device.
* @return : The corresponding device view page. Null if not visible.
*/
public ConnectedCupDeviceViewPage viewDevice(String deviceName) throws IOException {
WebElement deviceTable = driver.findElement(By.xpath(uiElementMapper.getElement("iot.devices.table.xpath")));
List<WebElement> data = deviceTable.findElements(By.cssSelector("a"));
@ -71,6 +90,12 @@ public class DevicesPage {
return null;
}
/**
* Method to extract the URL, which matches with the given parameters from an HTML element.
* @param element : WebElement, from which the URL should be extracted.
* @param lookupText : The parameters to be contained in the URL.
* @return : The URL String found. NULL if the URL is not found.
*/
private String getLink(WebElement element, String... lookupText) {
String link = element.getAttribute("href");
log.info("Link -----------------------> " + link);

@ -31,7 +31,8 @@ import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceTypeViewPage;
import java.io.IOException;
/**
* Device Enrollment page for new user
* Device Enrollment page.
* This page lists the all device types which are currently installed in the IOT server.
*/
public class EnrollDevicePage {
private WebDriver driver;
@ -48,6 +49,11 @@ public class EnrollDevicePage {
}
}
/**
* This method checks whether the Connected cup device is installed. If the device is installed correctly, it is
* displayed in this page.
* @return : True if the device is visible in the page. False otherwise.
*/
public boolean isInstalled() {
boolean check = UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
@ -60,6 +66,10 @@ public class EnrollDevicePage {
return false;
}
/**
* Method to perform the navigation to Device type view page of the Connected cup.
* @return : The corresponding Device type view page. Null, if the element is not visible.
*/
public ConnectedCupDeviceTypeViewPage gotoConnectedCupDeviceTypeViewPage() throws IOException {
boolean check = UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.xpath")));

@ -46,8 +46,9 @@ public class DeviceAddGroupPage {
/**
* @param name The group name that is need to be created.
* @param description the description for the group
* This method performs creation of a new device group.
* @param name : The group name that is need to be created.
* @param description : the description for the group
* @return The resultant page.
*/
public DeviceGroupsPage addNewGroup(String name, String description) throws IOException {
@ -68,6 +69,7 @@ public class DeviceAddGroupPage {
}
/**
* This method submits an empty form and returns the error message.
* @return The error string when trying to submit an empty form.
*/
public String submitEmptyForm() {

@ -28,6 +28,9 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
import java.util.List;
/**
* This class represents the Groups page.
*/
public class DeviceGroupsPage {
private WebDriver driver;
private UIElementMapper uiElementMapper;
@ -43,6 +46,10 @@ public class DeviceGroupsPage {
}
}
/**
* Method to go to the Add device group page, by clicking the Add group button.
* @return : Add device groups page.
*/
public DeviceAddGroupPage addNewGroup() throws IOException {
WebElement addNewGroupBtn = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.device.viewGroup.empty.addGroup.xpath")));
@ -50,6 +57,11 @@ public class DeviceGroupsPage {
return new DeviceAddGroupPage(driver);
}
/**
* This method checks whether the created group is visible in the UI.
* @param groupName : Name of the group created.
* @return : True if the group is visible. False otherwise.
*/
public boolean isGroupCreated(String groupName) {
WebElement table = driver.findElement(By.id(uiElementMapper.getElement("iot.device.table.id")));
List<WebElement> allGroupNames = table.findElements(By.tagName("h4"));
@ -59,7 +71,6 @@ public class DeviceGroupsPage {
return true;
}
}
return false;
}
}

@ -67,6 +67,10 @@ public class IOTAdminDashboard {
}
}
/**
* Performs the logout action.
* @return : The IOT login page
*/
public LoginPage logout() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click();
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
@ -74,31 +78,55 @@ public class IOTAdminDashboard {
return new LoginPage(driver);
}
/**
* Performs the navigation to Add device group page.
* @return : Add Device Group page.
*/
public DeviceAddGroupPage addGroup() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.device.group.addButton.xpath"))).click();
return new DeviceAddGroupPage(driver);
}
/**
* Performs the navigation to Group listing page.
* @return : Groups page.
*/
public DeviceGroupsPage viewGroups() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.device.group.viewButton.xpath"))).click();
return new DeviceGroupsPage(driver);
}
/**
* Navigates to the Add User page.
* @return : Add user page.
*/
public AddUserPage addUser() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.user.addButton.xpath"))).click();
return new AddUserPage(driver);
}
/**
* Navigates to the User Listing page.
* @return : User Listing page.
*/
public UserListingPage viewUser() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.user.viewButton.xpath"))).click();
return new UserListingPage(driver);
}
/**
* Navigates to the New device enrollment page.
* @return : Enroll Device page.
*/
public EnrollDevicePage enrollNewDevice() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.device.addBtn.xpath"))).click();
return new EnrollDevicePage(driver);
}
/**
* Navigates to the Devices listing page.
* @return : devices listing page.
*/
public DevicesPage viewDevices() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.device.viewBtn.xpath"))).click();
return new DevicesPage(driver);

@ -47,6 +47,10 @@ public class IOTHomePage {
}
}
/**
* Method to check the current User name
* @return : True if the user name matches the logged in user. False otherwise.
*/
public boolean checkUserName() {
String name = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).getText();
return name.contains(uiElementMapper.getElement("iot.user.login.username"));
@ -54,8 +58,9 @@ public class IOTHomePage {
/**
* Perform the logout action.
* */
* Performs the logout function.
* @return : IOT login page.
*/
public LoginPage logout() throws IOException {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.registered.name"))).click();
WebElement logout = driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.logout.link.xpath")));
@ -63,7 +68,10 @@ public class IOTHomePage {
return new LoginPage(driver);
}
//To enroll devices as user
/**
* Navigates to the New device enrollment page.
* @return : Enroll Device page.
*/
public EnrollDevicePage enrollNewDevice() throws IOException {
driver.findElement(By.xpath("iot.home.page.uuf-menu.xpath")).click();
driver.findElement(By.xpath("iot.home.page.uuf-menu.devicemgt.xpath")).click();
@ -71,13 +79,13 @@ public class IOTHomePage {
return new EnrollDevicePage(driver);
}
//To add new Device groups
public void goToGroupManagementPage() {
/**
* Performs the navigation to Add device group page.
* @return : Add Device Group page.
*/
public DeviceAddGroupPage addNewGroup() throws IOException {
driver.findElement(By.xpath("iot.home.page.uuf-menu.xpath")).click();
driver.findElement(By.xpath("iot.home.page.uuf-menu.groupmgt.xpath")).click();
}
public DeviceAddGroupPage addNewGroup() throws IOException {
driver.findElement(By.xpath("iot.device.viewGroup.empty.addGroup.xpath")).click();
return new DeviceAddGroupPage(driver);
}

@ -52,6 +52,7 @@ public class ConnectedCupDeviceInterface {
/**
* Method to perform the order coffee functionality.
* @return : True if the element is present and action is performed. False otherwise.
*/
public boolean orderCoffee() {
if (UIUtils.isElementPresent(log, driver, By.xpath(
@ -67,6 +68,7 @@ public class ConnectedCupDeviceInterface {
/**
* Method to change the temperature level.
* @param temp : The value to be set.
* @return : True if the element is present and value is set. False otherwise.
*/
public boolean changeTemperature(String temp) {
if (UIUtils.isElementPresent(log, driver, By.xpath(
@ -82,6 +84,7 @@ public class ConnectedCupDeviceInterface {
/**
* Method to change the Coffee level.
* @param level : The value to be set.
* @return : True if the element is present and value is set. False otherwise.
*/
public boolean changeCoffeeLevel(String level) {
if (UIUtils.isElementPresent(log, driver, By.xpath(

@ -46,6 +46,7 @@ public class ConnectedCupDeviceTypeViewPage {
/**
* This method verifies that the pop up modal for inserting a name for device is present.
* @return : True if the Modal pop up is displayed. False otherwise.
*/
public boolean isPopUpPresent() throws InterruptedException {
WebElement createInstanceBtn = driver.findElement(By.xpath(
@ -62,6 +63,7 @@ public class ConnectedCupDeviceTypeViewPage {
* the popup, user should be navigated to the device type view page again.
* This method checks the navigation and return true if navigation is correct.
* @param name : Name for the device.
* @return : True if navigates to the Device type view page without errors. False otherwise.
*/
public boolean enrollDevice(String name) {

@ -66,6 +66,7 @@ public class ConnectedCupDeviceViewPage {
/**
* This method executes Connected cup sample web app.
* @return : The Connected cup web page.
*/
public ConnectedCupDeviceInterface gotoDevice() throws IOException {
WebDriverWait wait = new WebDriverWait(driverServer, UIUtils.webDriverTime);

@ -94,7 +94,16 @@ public class NewUserRegisterPage {
handleAction(firstName, lastName, email, userName, password, confirmPassword);
}
public void handleAction(String firstName, String lastName, String email, String userName, String password,
/**
* Support method to populate the User registration form.
* @param firstName : First name of the user.
* @param lastName : Last name of the user.
* @param email : E mail of the user.
* @param userName : User name of the user.
* @param password : Password for the user.
* @param confirmPassword : Confirmation password.
*/
private void handleAction(String firstName, String lastName, String email, String userName, String password,
String confirmPassword) {
clearForm();
firstNameField.sendKeys(firstName);
@ -106,7 +115,10 @@ public class NewUserRegisterPage {
registerButton.click();
}
public void clearForm() {
/**
* Support method to clear the Registration form.
*/
private void clearForm() {
firstNameField.clear();
lastNameField.clear();
emailField.clear();

@ -27,10 +27,8 @@ import java.io.IOException;
* This class represents the confirmation page for adding a new user.
*/
public class UserAddedConfirmationPage {
private WebDriver driver;
public UserAddedConfirmationPage(WebDriver driver) throws IOException {
this.driver = driver;
UIElementMapper uiElementMapper = UIElementMapper.getInstance();
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click();

@ -40,6 +40,7 @@ public class UserListingPage {
}
/**
* Performs the delete user action.
* @return After deleting a user, returns back to the user listing page.
*/
public UserListingPage deleteUser() throws IOException, InterruptedException {

Loading…
Cancel
Save