forked from community/product-iots
parent
890209e3de
commit
28879b416f
@ -0,0 +1,25 @@
|
||||
package org.wso2.iot.integration.ui.pages.devices;
|
||||
|
||||
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.UIElementMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DevicesPage {
|
||||
private WebDriver driver;
|
||||
private UIElementMapper uiElementMapper;
|
||||
|
||||
public DevicesPage(WebDriver driver) throws IOException {
|
||||
this.driver = driver;
|
||||
this.uiElementMapper = UIElementMapper.getInstance();
|
||||
|
||||
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
|
||||
if (!webDriverWait.until(ExpectedConditions.titleContains("Device Management | IoT Server"))) {
|
||||
throw new IllegalStateException("This is not the Device Management page");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
/*
|
||||
* 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.devices;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
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.UIConstants;
|
||||
import org.wso2.iot.integration.ui.pages.UIElementMapper;
|
||||
import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceTypeViewPage;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Device Enrollment page for new user
|
||||
*/
|
||||
public class EnrollDevicePage {
|
||||
private static final Log log = LogFactory.getLog(EnrollDevicePage.class);
|
||||
private WebDriver driver;
|
||||
private UIElementMapper uiElementMapper;
|
||||
|
||||
public EnrollDevicePage(WebDriver driver) throws IOException {
|
||||
this.driver = driver;
|
||||
this.uiElementMapper = UIElementMapper.getInstance();
|
||||
|
||||
WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
|
||||
if (!webDriverWait.until(ExpectedConditions.titleContains("Device Types | IoT Server"))) {
|
||||
throw new IllegalStateException("This is not the Device Enrollment page");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInstalled(String name) {
|
||||
|
||||
return driver.findElement(By.id("#" + name.toLowerCase())) != null;
|
||||
|
||||
// WebElement sample = null;
|
||||
// try {
|
||||
// sample = driver.findElement(By.id("#"+name.toLowerCase()));
|
||||
// } catch (NoSuchElementException e){
|
||||
// log.error("No element found for id: " + name);
|
||||
// }
|
||||
// return sample != null;
|
||||
}
|
||||
|
||||
public ConnectedCupDeviceTypeViewPage gotoConnectedCupDeviceTypeViewPage() throws IOException {
|
||||
WebElement tryBtn = driver.findElement(By.id(uiElementMapper.getElement("iot.sample.connectedcup.try.btn.id")));
|
||||
tryBtn.click();
|
||||
return new ConnectedCupDeviceTypeViewPage(driver);
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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.samples;
|
||||
|
||||
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.wso2.iot.integration.ui.pages.UIElementMapper;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class ConnectedCupDeviceTypeViewPage {
|
||||
private WebDriver driver;
|
||||
private UIElementMapper uiElementMapper;
|
||||
|
||||
public ConnectedCupDeviceTypeViewPage(WebDriver driver) throws IOException {
|
||||
this.driver = driver;
|
||||
this.uiElementMapper = UIElementMapper.getInstance();
|
||||
|
||||
// WebDriverWait webDriverWait = new WebDriverWait(driver, UIConstants.webDriverTimeOut);
|
||||
if (driver.findElement(By.xpath(
|
||||
uiElementMapper.getElement("iot.sample.connectedcup.page.title"))).getText().
|
||||
contains("Connected Cup")) {
|
||||
throw new IllegalStateException("This is not the Connected cup device type view page");
|
||||
}
|
||||
}
|
||||
|
||||
public void enrollDevice(String name) {
|
||||
WebElement createInstanceBtn = driver.findElement(By.xpath(
|
||||
uiElementMapper.getElement("iot.sample.connectedcup.createInstanceBtn.xpath")));
|
||||
createInstanceBtn.click();
|
||||
WebElement nameField = driver.findElement(By.xpath(
|
||||
uiElementMapper.getElement("iot.sample.connectedcup.createInstance.nameField.xpath")));
|
||||
WebElement createButton = driver.findElement(By.xpath(
|
||||
uiElementMapper.getElement("iot.sample.connectedcup.createInstance.downloadBtn.xpath")));
|
||||
nameField.sendKeys(name);
|
||||
createButton.click();
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package org.wso2.carbon.iot.integration.web.ui.test.samples;
|
||||
|
||||
/**
|
||||
* Created by menaka on 2/29/16.
|
||||
*/
|
||||
public class SampleEnrollmentTest {
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/*
|
||||
* 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.carbon.iot.integration.web.ui.test.samples;
|
||||
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
import org.wso2.carbon.automation.extensions.selenium.BrowserManager;
|
||||
import org.wso2.carbon.iot.integration.web.ui.test.LoginUtils;
|
||||
import org.wso2.iot.integration.ui.pages.IOTIntegrationUIBaseTestCase;
|
||||
import org.wso2.iot.integration.ui.pages.devices.EnrollDevicePage;
|
||||
import org.wso2.iot.integration.ui.pages.home.IOTAdminDashboard;
|
||||
import org.wso2.iot.integration.ui.pages.samples.ConnectedCupDeviceTypeViewPage;
|
||||
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.xpath.XPathExpressionException;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SampleInstallationVerification extends IOTIntegrationUIBaseTestCase {
|
||||
|
||||
private WebDriver driver;
|
||||
private EnrollDevicePage enrollDevicePage;
|
||||
private IOTAdminDashboard adminDashboard;
|
||||
|
||||
@BeforeClass(alwaysRun = true)
|
||||
public void setup() throws XPathExpressionException, XMLStreamException, IOException {
|
||||
super.init();
|
||||
driver = BrowserManager.getWebDriver();
|
||||
LoginUtils.login(driver, automationContext, getWebAppURL());
|
||||
adminDashboard = new IOTAdminDashboard(driver);
|
||||
}
|
||||
|
||||
@Test(description = "Verify the sample is available in Virtual devices section.")
|
||||
public void installationVerificationTest() throws IOException {
|
||||
enrollDevicePage = adminDashboard.enrollNewDevice();
|
||||
Assert.assertTrue(enrollDevicePage.isInstalled("ConnectedCup"));
|
||||
// Assert.assertTrue(enrollDevicePage.isInstalled("Virtual Fire Alarm"));
|
||||
}
|
||||
|
||||
@Test(description = "Verify the installation of UI components.", dependsOnMethods =
|
||||
{"installationVerificationTest"})
|
||||
public void verifyNavigationToDeviceTypeView() throws IOException {
|
||||
ConnectedCupDeviceTypeViewPage connectedCupDeviceTypeViewPage = enrollDevicePage.gotoConnectedCupDeviceTypeViewPage();
|
||||
}
|
||||
|
||||
@AfterClass(alwaysRun = true)
|
||||
public void teardown() {
|
||||
driver.quit();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue