diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java index f76f5b60..8a5e25aa 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/graphs/GraphHandler.java @@ -70,7 +70,7 @@ public class GraphHandler { Graph g = new Graph(); String key = e.getAttribute("id").split("-")[1]; g.setGraphId(key.toLowerCase().replace(" ", "")); - String xAxis = e.findElement(By.xpath(uiElementMapper.getElement("ot.stat.graph.xAxis.xpath"))).getText(); + String xAxis = e.findElement(By.xpath(uiElementMapper.getElement("iot.stat.graph.xAxis.xpath"))).getText(); g.setxAxis(xAxis); String yAxis = e.findElement(By.xpath("//*[contains(@id, \"y_axis-" + key + "\")]")).getText(); g.setyAxis(yAxis); diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java index 67a9b156..095e28fc 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/home/IOTAdminDashboard.java @@ -132,5 +132,5 @@ public class IOTAdminDashboard { return new DevicesPage(driver); } - //ToDo : Need to add device and policy methods + //ToDo : Need to add policy methods } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java index 8dbb3136..a4124980 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceInterface.java @@ -76,6 +76,7 @@ public class ConnectedCupDeviceInterface { WebElement tempSlider = driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.temperature.xpath"))); moveSlider(tempSlider, Integer.parseInt(temp)); + driver.manage().timeouts().implicitlyWait(UIUtils.webDriverTime, TimeUnit.SECONDS); return true; } return false; @@ -107,6 +108,5 @@ public class ConnectedCupDeviceInterface { Actions move = new Actions(driver); Action action = move.dragAndDropBy(slider, 0, val).build(); action.perform(); - } } \ No newline at end of file diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java index dec999dc..eddc3734 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceTypeViewPage.java @@ -21,6 +21,8 @@ package org.wso2.iot.integration.ui.pages.samples; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; +import org.openqa.selenium.support.ui.ExpectedConditions; +import org.openqa.selenium.support.ui.WebDriverWait; import org.wso2.iot.integration.ui.pages.UIUtils; import org.wso2.iot.integration.ui.pages.UIElementMapper; @@ -52,8 +54,9 @@ public class ConnectedCupDeviceTypeViewPage { WebElement createInstanceBtn = driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.createInstanceBtn.xpath"))); createInstanceBtn.click(); - - Thread.sleep(UIUtils.threadTimeout); + WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut); + wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath( + uiElementMapper.getElement("iot.sample.modal.popup.xpath"))))); return driver.findElement(By.xpath(uiElementMapper.getElement("iot.sample.modal.popup.xpath"))).isDisplayed(); } @@ -66,7 +69,6 @@ public class ConnectedCupDeviceTypeViewPage { * @return : True if navigates to the Device type view page without errors. False otherwise. */ public boolean enrollDevice(String name) { - WebElement nameField = driver.findElement(By.xpath( uiElementMapper.getElement("iot.sample.connectedcup.createInstance.nameField.xpath"))); WebElement createButton = driver.findElement(By.xpath( diff --git a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java index 4b3564be..61c14b72 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java +++ b/modules/integration/tests-common/web-ui-pages/src/main/java/org/wso2/iot/integration/ui/pages/samples/ConnectedCupDeviceViewPage.java @@ -78,7 +78,6 @@ public class ConnectedCupDeviceViewPage { return new ConnectedCupDeviceInterface(driverDevice); } - /** * Gets the connected cup device web app URL. * @return : Link of the connected cup device web app. @@ -91,7 +90,6 @@ public class ConnectedCupDeviceViewPage { uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath"))).getAttribute("href"); } - /** * This method checks whether there are expected number of graphs are available in the UI. * @param count : Number of graphs expected. @@ -101,7 +99,6 @@ public class ConnectedCupDeviceViewPage { return handler.getGraphCount() == count; } - /** * Checks whether the selected graph axes represent the given values. * @param axis : Graph axis. X or Y @@ -119,6 +116,7 @@ public class ConnectedCupDeviceViewPage { return graphMap.get(graphId).getyAxis().contains(axisName); } } + log.error("There are no graphs found."); return false; } @@ -131,12 +129,13 @@ public class ConnectedCupDeviceViewPage { public boolean graphLegendName(String graphId, String legend) { log.info(graphMap.toString()); if (graphMap.size() != 0) { - try { + if (graphMap.get(graphId) != null){ return graphMap.get(graphId).getLegend().contains(legend); - } catch (NullPointerException e) { - log.info("Null Pointer" + e.getMessage()); } + log.error(String.format("Graph for %s is not found.", graphId)); + return false; } + log.error("There are no graphs found."); return false; } diff --git a/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties b/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties index 6e370329..d5ee382e 100644 --- a/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties +++ b/modules/integration/tests-common/web-ui-pages/src/main/resources/mapper.properties @@ -20,12 +20,12 @@ iot.user.add.firstname=firstname iot.user.add.lastname=lastname -iot.user.add.username=username -iot.user.add.password=password +iot.user.add.username=testUser +iot.user.add.password=testPassword iot.user.add.email=username@wso2.com -iot.user.login.username=username -iot.user.login.password=password +iot.user.login.username=testUser +iot.user.login.password=testPassword # User registration and login ui---------------------------------------------------------------------------------------- diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java index 190d4437..aeb3fe50 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/common/Constants.java @@ -60,7 +60,7 @@ public class Constants { public static final String ADD_USER_FIRST_NAME_ERROR_MSG = "Firstname is a required field. It cannot be empty."; public static final String ADD_USER_LAST_NAME_ERROR_MSG = "Lastname is a required field. It cannot be empty."; public static final String ADD_USER_NO_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty."; - public static final String ADD_USER_WRONG_EMAIL_ERROR_MSG = "Email is a required field. It cannot be empty."; + public static final String ADD_USER_WRONG_EMAIL_ERROR_MSG = "Provided email is invalid. Please check."; public static final String ALERT_NOT_PRESENT = "Alert is not present."; diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java index 7e2d2da0..f55f4326 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/login/LoginTest.java @@ -46,8 +46,8 @@ public class LoginTest extends IOTIntegrationUIBaseTestCase { @Test(description = "Verify login to IOT server dashboard") public void testAdminLogin() throws IOException, XPathExpressionException { - LoginPage test = new LoginPage(driver); - IOTAdminDashboard dashboard = test.loginAsAdmin( + LoginPage loginPage = new LoginPage(driver); + IOTAdminDashboard dashboard = loginPage.loginAsAdmin( automationContext.getSuperTenant().getTenantAdmin().getUserName(), automationContext.getSuperTenant().getTenantAdmin().getPassword()); dashboard.logout(); diff --git a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java index d6751b4a..a64560a6 100644 --- a/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java +++ b/modules/integration/tests-iot-web-ui/src/test/java/org/wso2/carbon/iot/integration/web/ui/test/samples/SampleInstallationTest.java @@ -190,7 +190,8 @@ public class SampleInstallationTest extends IOTIntegrationUIBaseTestCase { } } } catch (RemoteException | LogViewerLogViewerException e) { - e.printStackTrace(); + log.error("Error reading logs. \n" + e.getMessage()); + Assert.assertTrue(false); } } };