Changes and Improvements as per the code review.

application-manager-new
Menaka Jayawardena 7 years ago
parent 1ddd7e8b61
commit 399136daae

@ -80,11 +80,11 @@ 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> anchors = deviceTable.findElements(By.cssSelector("a"));
for (WebElement e : data) { for (WebElement element : anchors) {
String s = getLink(e, "/device/connectedcup?id="); String connectedCupLink = getLink(element, "/device/connectedcup?id=");
if (s != null) { if (connectedCupLink != null) {
driver.get(s); driver.get(connectedCupLink);
return new ConnectedCupDeviceViewPage(driver, deviceName); return new ConnectedCupDeviceViewPage(driver, deviceName);
} }
} }
@ -100,12 +100,11 @@ public class DevicesPage {
private String getLink(WebElement element, String... lookupText) { private String getLink(WebElement element, String... lookupText) {
String link = element.getAttribute("href"); String link = element.getAttribute("href");
boolean check = true; boolean check = true;
for (String s : lookupText) { for (String text : lookupText) {
if (!link.contains(s)) { if (!link.contains(text)) {
check = false; check = false;
} }
} }
return check ? link : null; return check ? link : null;
} }
} }

@ -81,9 +81,8 @@ public class EnrollDevicePage {
tryBtn.click(); tryBtn.click();
return new ConnectedCupDeviceTypeViewPage(driver); return new ConnectedCupDeviceTypeViewPage(driver);
} else { } else {
log.error("Element not found..........................."); log.error("Element not found!");
return null; return null;
} }
} }
} }

@ -1,3 +1,20 @@
/*
* Copyright (c) 2017, 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.error; package org.wso2.iot.integration.ui.pages.error;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
@ -24,7 +41,6 @@ public class IOTErrorPage {
throw new IllegalStateException("This is not the Error page"); throw new IllegalStateException("This is not the Error page");
} }
} }
public boolean isErrorPresent() { public boolean isErrorPresent() {
return this.isErrorPage; return this.isErrorPage;
} }

@ -60,5 +60,4 @@ public class Graph {
return String.format("The graph for graph id : %s, X - axis : %s, Y - axis : %s, legend : %s ", graphId, return String.format("The graph for graph id : %s, X - axis : %s, Y - axis : %s, legend : %s ", graphId,
xAxis, yAxis, legend); xAxis, yAxis, legend);
} }
} }

@ -47,7 +47,6 @@ public class DeviceAddGroupPage {
} }
} }
/** /**
* This method performs creation of a new device group. * This method performs creation of a new device group.
* @param name : The group name that is need to be created. * @param name : The group name that is need to be created.
@ -91,5 +90,4 @@ public class DeviceAddGroupPage {
return driver.findElement(By.xpath( return driver.findElement(By.xpath(
uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText(); uiElementMapper.getElement("iot.device.groups.add.emptyfrom.error"))).getText();
} }
} }

@ -132,6 +132,5 @@ public class IOTAdminDashboard {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.device.viewBtn.xpath"))).click(); driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.device.viewBtn.xpath"))).click();
return new DevicesPage(driver); return new DevicesPage(driver);
} }
//ToDo : Need to add policy methods //ToDo : Need to add policy methods
} }

@ -57,7 +57,6 @@ public class IOTHomePage {
return name.contains(uiElementMapper.getElement("iot.user.login.username")); return name.contains(uiElementMapper.getElement("iot.user.login.username"));
} }
/** /**
* Performs the logout function. * Performs the logout function.
* @return : IOT login page. * @return : IOT login page.
@ -90,7 +89,5 @@ public class IOTHomePage {
driver.findElement(By.xpath("iot.device.viewGroup.empty.addGroup.xpath")).click(); driver.findElement(By.xpath("iot.device.viewGroup.empty.addGroup.xpath")).click();
return new DeviceAddGroupPage(driver); return new DeviceAddGroupPage(driver);
} }
//ToDo : To add policies //ToDo : To add policies
} }

@ -101,5 +101,4 @@ public class LoginPage {
registerLink.click(); registerLink.click();
return new NewUserRegisterPage(driver); return new NewUserRegisterPage(driver);
} }
} }

@ -110,5 +110,4 @@ public class ConnectedCupDeviceInterface {
Action action = move.dragAndDropBy(slider, 0, val).build(); Action action = move.dragAndDropBy(slider, 0, val).build();
action.perform(); action.perform();
} }
} }

@ -17,7 +17,6 @@
*/ */
package org.wso2.iot.integration.ui.pages.samples; package org.wso2.iot.integration.ui.pages.samples;
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.openqa.selenium.WebElement;
@ -79,5 +78,4 @@ public class ConnectedCupDeviceTypeViewPage {
return driver.findElement(By.xpath( return driver.findElement(By.xpath(
uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().contains("Connected Cup"); uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().contains("Connected Cup");
} }
} }

@ -170,5 +170,4 @@ public class ConnectedCupDeviceViewPage {
return false; return false;
} }
} }
} }

@ -27,7 +27,6 @@ import org.wso2.iot.integration.ui.pages.UIElementMapper;
import java.io.IOException; import java.io.IOException;
/** /**
* This class represents the add user page of the IOT server. * This class represents the add user page of the IOT server.
*/ */
@ -76,5 +75,4 @@ public class AddUserPage {
return new UserAddedConfirmationPage(driver); return new UserAddedConfirmationPage(driver);
} }
} }

@ -48,5 +48,4 @@ public class EditUserPage {
public void editUser(String password, String firstName, String lastName) { public void editUser(String password, String firstName, String lastName) {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath"))); driver.findElement(By.xpath(uiElementMapper.getElement("iot.user.add.input.password.xpath")));
} }
} }

@ -127,5 +127,4 @@ public class NewUserRegisterPage {
passwordField.clear(); passwordField.clear();
passwordConfirmationField.clear(); passwordConfirmationField.clear();
} }
} }

@ -33,5 +33,4 @@ public class UserAddedConfirmationPage {
driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click(); driver.findElement(By.xpath(uiElementMapper.getElement("iot.admin.addUser.view.btn.xpath"))).click();
} }
} }

@ -64,5 +64,4 @@ public class UserListingPage {
return new UserListingPage(driver); return new UserListingPage(driver);
} }
} }

@ -43,5 +43,4 @@ public class ViewUserPage {
throw new IllegalStateException("This is not the User view page"); throw new IllegalStateException("This is not the User view page");
} }
} }
} }

Loading…
Cancel
Save