Class name changed

application-manager-new
Menaka Madushanka 9 years ago
parent 6858fb8a85
commit 0ce1d75c61

@ -0,0 +1,45 @@
/*
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.iot.integration.ui.pages;
import org.apache.commons.logging.Log;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class UIUtils {
public static long webDriverTimeOut = 10;
public static long webDriverTime = 60;
public static int threadTimeout = 1000;
public static boolean isElementPresent(Log log, WebDriver driver, By by) {
try {
WebDriverWait wait = new WebDriverWait(driver, webDriverTime);
wait.until(ExpectedConditions.presenceOfElementLocated(by));
driver.findElement(by);
return true;
} catch (NoSuchElementException e) {
log.error(by.toString() + " is not present");
return false;
}
}
}

@ -24,7 +24,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceViewPage;
@ -40,7 +40,7 @@ public class DevicesPage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Device Management | IoT Server"))) {
throw new IllegalStateException("This is not the Device Management page");
}

@ -20,12 +20,11 @@ package org.wso2.iot.integration.ui.pages.devices;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.openqa.selenium.By;
import org.openqa.selenium.NoSuchElementException;
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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceTypeViewPage;
@ -43,14 +42,14 @@ public class EnrollDevicePage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Device Types | IoT Server"))) {
throw new IllegalStateException("This is not the Device Enrollment page");
}
}
public boolean isInstalled() {
boolean check = UIConstants.isElementPresent(log, driver, By.xpath(
boolean check = UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
if (check) {
WebElement deviceDiv = driver.findElement(By.xpath(
@ -62,7 +61,7 @@ public class EnrollDevicePage {
}
public ConnectedCupDeviceTypeViewPage gotoConnectedCupDeviceTypeViewPage() throws IOException {
boolean check = UIConstants.isElementPresent(log, driver,By.xpath(
boolean check = UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.xpath")));
if (check){
WebElement deviceDiv = driver.findElement(By.xpath(

@ -25,7 +25,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -61,7 +61,7 @@ public class GraphHandler {
*/
public HashMap<String, Graph> getGraphMap() {
HashMap<String, Graph> graphMap = new HashMap<>();
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath(
uiElementMapper.getElement("iot.stat.graph.wrapper.xpath")))));
List<WebElement> graphs = driver.findElements(By.xpath(
@ -139,7 +139,7 @@ public class GraphHandler {
*/
public boolean isPathGetValues(WebElement graph, String val) {
WebElement graphContainer = getGraph(graph, uiElementMapper.getElement("iot.stat.graph.class.name"));
driver.manage().timeouts().implicitlyWait(UIConstants.webDriverTimeOut, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(UIUtils.webDriverTimeOut, TimeUnit.SECONDS);
String[] values;
if (graphContainer != null) {
values = graphContainer.findElement(By.tagName("path")).getAttribute("d").split(",");

@ -22,11 +22,10 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class DeviceGroupsPage {
@ -36,7 +35,7 @@ public class DeviceGroupsPage {
public DeviceGroupsPage(WebDriver driver) throws IOException {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.textToBePresentInElement(driver.findElement(By.xpath(
uiElementMapper.getElement("iot.device.groups.view.header.xpath"))), "GROUPS"))) {

@ -22,7 +22,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage;
import org.wso2.iot.integration.ui.pages.groups.DeviceAddGroupPage;
@ -42,7 +42,7 @@ public class IOTHomePage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
// Check that we're on the right page.
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!wait.until(ExpectedConditions.titleIs("Device Management | IoT Server"))) {
throw new IllegalStateException("This is not the home page");
}

@ -24,7 +24,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard;
import org.wso2.iot.integration.ui.pages.home.IOTHomePage;
@ -47,7 +47,7 @@ public class LoginPage {
public LoginPage(WebDriver driver) throws IOException {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Login | IoT Server"))) {
throw new IllegalStateException("This is not the Login page");
@ -102,7 +102,7 @@ public class LoginPage {
}
public void validateForm(String username, String password) {
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(
uiElementMapper.getElement("iot.user.login.input.username.xpath"))));
wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath(

@ -21,7 +21,7 @@ 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.wso2.iot.integration.ui.pages.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -45,7 +45,7 @@ public class ConnectedCupDeviceTypeViewPage {
uiElementMapper.getElement("iot.sample.connectedcup.createInstanceBtn.xpath")));
createInstanceBtn.click();
Thread.sleep(UIConstants.threadTimeout);
Thread.sleep(UIUtils.threadTimeout);
return driver.findElement(By.xpath(uiElementMapper.getElement("iot.sample.modal.popup.xpath"))).isDisplayed();
}

@ -24,7 +24,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.graphs.Graph;
import org.wso2.iot.integration.ui.pages.graphs.GraphHandler;
@ -56,7 +56,7 @@ public class ConnectedCupDeviceViewPage {
}
public VirtualSampleViewPage gotoDevice() throws IOException {
WebDriverWait wait = new WebDriverWait(driverServer, UIConstants.webDriverTime);
WebDriverWait wait = new WebDriverWait(driverServer, UIUtils.webDriverTime);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath"))));
String link = driverServer.findElement(By.xpath(
@ -66,7 +66,7 @@ public class ConnectedCupDeviceViewPage {
}
public String getDeviceLink() {
WebDriverWait wait = new WebDriverWait(driverServer, UIConstants.webDriverTime);
WebDriverWait wait = new WebDriverWait(driverServer, UIUtils.webDriverTime);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.gotodevice.xpath"))));
return driverServer.findElement(By.xpath(

@ -26,7 +26,7 @@ import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.wso2.iot.integration.ui.pages.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -40,14 +40,14 @@ public class VirtualSampleViewPage {
public VirtualSampleViewPage(WebDriver driver) throws IOException {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Connected Coffee Cup"))) {
throw new IllegalStateException("This is not the Connected cup device page");
}
}
public boolean orderCoffee() {
if (UIConstants.isElementPresent(log, driver, By.xpath(
if (UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.orderCoffee.xpath")))) {
WebElement orderBtn = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.sample.orderCoffee.xpath")));
@ -58,7 +58,7 @@ public class VirtualSampleViewPage {
}
public boolean changeTemperature(String temp) {
if (UIConstants.isElementPresent(log, driver, By.xpath(
if (UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.temperature.xpath")))) {
WebElement tempSlider = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.sample.temperature.xpath")));
@ -69,12 +69,12 @@ public class VirtualSampleViewPage {
}
public boolean changeCoffeeLevel(String level) {
if (UIConstants.isElementPresent(log, driver, By.xpath(
if (UIUtils.isElementPresent(log, driver, By.xpath(
uiElementMapper.getElement("iot.sample.coffee.level.xpath")))) {
WebElement lvlSlider = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.sample.coffee.level.xpath")));
moveSlider(lvlSlider, Integer.parseInt(level));
driver.manage().timeouts().implicitlyWait(UIConstants.webDriverTime, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(UIUtils.webDriverTime, TimeUnit.SECONDS);
return true;
}
return false;

@ -22,7 +22,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -39,7 +39,7 @@ public class AddUserPage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))) {
throw new IllegalStateException("This is not the Add User page");
}

@ -23,7 +23,7 @@ import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.wso2.iot.integration.ui.pages.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
/**
@ -38,7 +38,7 @@ public class EditUserPage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))){
throw new IllegalStateException("This is not the Edit User page");
}

@ -22,7 +22,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import org.wso2.iot.integration.ui.pages.login.LoginPage;
@ -47,7 +47,7 @@ public class NewUserRegisterPage {
UIElementMapper uiElementMapper = UIElementMapper.getInstance();
// Check that we're on the right page.
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("Register | IoT Server"))) {
throw new IllegalStateException("This is not the Register page");
}

@ -22,7 +22,7 @@ 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.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException;
@ -46,7 +46,7 @@ public class UserListingPage {
WebElement deleteBtn = driver.findElement(By.xpath(
uiElementMapper.getElement("iot.admin.deleteUser.btn.xpath")));
WebDriverWait wait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait wait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
wait.until(ExpectedConditions.visibilityOf(deleteBtn));
deleteBtn.click();
@ -55,7 +55,7 @@ public class UserListingPage {
wait.until(ExpectedConditions.visibilityOf(deleteConfirmationBtn));
deleteConfirmationBtn.click();
Thread.sleep(UIConstants.threadTimeout);
Thread.sleep(UIUtils.threadTimeout);
WebElement deleteSuccessBtn = driver.findElement(
By.xpath(uiElementMapper.getElement("iot.admin.deleteUser.success.link.xpath")));
deleteSuccessBtn.click();

@ -22,7 +22,7 @@ import org.apache.commons.logging.LogFactory;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.wso2.iot.integration.ui.pages.UIConstants;
import org.wso2.iot.integration.ui.pages.UIUtils;
import org.wso2.iot.integration.ui.pages.UIElementMapper;
/**
@ -37,7 +37,7 @@ public class ViewUserPage {
this.driver = driver;
this.uiElementMapper = UIElementMapper.getInstance();
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
WebDriverWait webDriverWait = new WebDriverWait(driver, UIUtils.webDriverTimeOut);
if (!webDriverWait.until(ExpectedConditions.titleContains("User Management | IoT Server"))){
throw new IllegalStateException("This is not the User view page");
}

Loading…
Cancel
Save