From 26def287eee21b36b5920e2fe832ce28ddc3a482 Mon Sep 17 00:00:00 2001 From: Mohammad Rahman Date: Thu, 17 Dec 2020 16:26:14 -0500 Subject: [PATCH] Added new tests, bug fixes for existing ones. --- .../automationTests/DashboardTest.java | 123 +- .../automationTests/LoginTest.java | 98 +- .../automationTests/NetworkTest.java | 1081 +++++++++++------ .../automationTests/ProfilesTest.java | 200 ++- .../automationTests/SystemTests.java | 479 +++++--- .../automationTests/UsersTest.java | 470 +++++++ .../automationTests/testSuite.java | 9 +- 7 files changed, 1712 insertions(+), 748 deletions(-) create mode 100644 CICD_AP_CLOUDSDK/automationTests/UsersTest.java diff --git a/CICD_AP_CLOUDSDK/automationTests/DashboardTest.java b/CICD_AP_CLOUDSDK/automationTests/DashboardTest.java index 6c71b368a..b024ffd68 100644 --- a/CICD_AP_CLOUDSDK/automationTests/DashboardTest.java +++ b/CICD_AP_CLOUDSDK/automationTests/DashboardTest.java @@ -27,20 +27,29 @@ public class DashboardTest { WebDriver driver; static APIClient client; static long runId; +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; + @BeforeClass public static void startTest() throws Exception { client = new APIClient("https://telecominfraproject.testrail.com"); client.setUser("syama.devi@connectus.ai"); - client.setPassword("Connectus123$"); + client.setPassword("Connect123$"); JSONArray c = (JSONArray) client.sendGet("get_runs/5"); runId = new Long(0); Calendar cal = Calendar.getInstance(); //Months are indexed 0-11 so add 1 for current month int month = cal.get(Calendar.MONTH) + 1; - String date = "UI Automation Run - " + cal.get(Calendar.DATE) + "/" + month + "/" + cal.get(Calendar.YEAR); - + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); for (int a = 0; a < c.size(); a++) { if (((JSONObject) c.get(a)).get("name").equals(date)) { runId = (Long) ((JSONObject) c.get(a)).get("id"); @@ -69,6 +78,14 @@ public class DashboardTest { driver.findElement(By.xpath("//*[@id=\"login\"]/button/span")).click(); } + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + public void networkScreen() throws Exception { driver.findElement(By.linkText("Network")).click(); } @@ -84,10 +101,7 @@ public class DashboardTest { Thread.sleep(2500); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Number of AP's provisioned cannot be found"); } @@ -108,10 +122,7 @@ public class DashboardTest { } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Number of AP's provisioned cannot be found"); } return 0; @@ -124,10 +135,7 @@ public class DashboardTest { int displ = Integer.parseInt(displayed.substring(displayed.length()-2)); return displ; } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Number of total devices associated cannot be found"); } @@ -139,10 +147,7 @@ public class DashboardTest { try { }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Number of total devices associated cannot be found"); } @@ -150,22 +155,18 @@ public class DashboardTest { List lines = driver.findElements(By.cssSelector("[class^='highcharts-tracker-line']")); if (lines.size()!= 5) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } - Assert.assertEquals("Graphs not displayed", 5, lines.size()); + } public int countRows(int testId) throws MalformedURLException, IOException, APIException { try { }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } WebElement tbl = driver.findElement(By.xpath("//table")); List rows = tbl.findElements(By.tagName("tr")); @@ -176,10 +177,8 @@ public class DashboardTest { try { }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } WebElement tbl = driver.findElement(By.xpath("//table")); List rows = tbl.findElements(By.tagName("tr")); @@ -199,6 +198,30 @@ public class DashboardTest { return count; } + public void verifyClientDevicesGraphs(int testId) throws MalformedURLException, IOException, APIException, InterruptedException { + List points = driver.findElements(By.cssSelector("[class^='highcharts-point']")); + points.get(1).click(); + points.get(2).click(); + Thread.sleep(1000); + List lines = driver.findElements(By.cssSelector("[class^='highcharts-tracker-line']")); + if (!lines.get(1).getAttribute("visibility").equals("hidden")||!lines.get(2).getAttribute("visibility").equals("hidden")) { + failure(testId); + fail(); + } + } + + public void verifyTrafficGraphs(int testId) throws MalformedURLException, IOException, APIException, InterruptedException { + List points = driver.findElements(By.cssSelector("[class^='highcharts-point']")); + points.get(3).click(); + points.get(4).click(); + Thread.sleep(1000); + List lines = driver.findElements(By.cssSelector("[class^='highcharts-tracker-line']")); + if (!lines.get(3).getAttribute("visibility").equals("hidden")||!lines.get(4).getAttribute("visibility").equals("hidden")) { + failure(testId); + fail(); + } + } + public void verifyDashboardScreenDetails(int testId) throws MalformedURLException, IOException, APIException { Map data = new HashMap(); try { @@ -307,6 +330,42 @@ public class DashboardTest { JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5220", data); } + + //C5634 + @Test + public void clientDevicesGraphsTest() throws Exception { + int testId = 5634; + Map data = new HashMap(); + DashboardTest obj = new DashboardTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(5000); + obj.verifyClientDevicesGraphs(testId); + Thread.sleep(2000); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + + //C5635 + @Test + public void trafficGraphsTest() throws Exception { + int testId = 5635; + + DashboardTest obj = new DashboardTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(5000); + obj.verifyTrafficGraphs(testId); + Thread.sleep(2000); + obj.closeBrowser(); + + Map data = new HashMap(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } // @Test // void devicesDetailsTest() throws Exception { diff --git a/CICD_AP_CLOUDSDK/automationTests/LoginTest.java b/CICD_AP_CLOUDSDK/automationTests/LoginTest.java index 0170f16c9..5983c7590 100644 --- a/CICD_AP_CLOUDSDK/automationTests/LoginTest.java +++ b/CICD_AP_CLOUDSDK/automationTests/LoginTest.java @@ -35,21 +35,29 @@ public class LoginTest { WebDriver driver, driver2; static APIClient client; static long runId; +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; @BeforeClass public static void startTest() throws Exception { client = new APIClient("https://telecominfraproject.testrail.com"); client.setUser("syama.devi@connectus.ai"); - client.setPassword("Connectus123$"); + client.setPassword("Connect123$"); JSONArray c = (JSONArray) client.sendGet("get_runs/5"); runId = new Long(0); Calendar cal = Calendar.getInstance(); //Months are indexed 0-11 so add 1 for current month int month = cal.get(Calendar.MONTH) + 1; - String date = "UI Automation Run - " + cal.get(Calendar.DATE) + "/" + month + "/" + cal.get(Calendar.YEAR); - + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); for (int a = 0; a < c.size(); a++) { if (((JSONObject) c.get(a)).get("name").equals(date)) { runId = (Long) ((JSONObject) c.get(a)).get("id"); @@ -58,11 +66,10 @@ public class LoginTest { } public void launchBrowser() { - System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver"); -// System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver");System.setProperty("webdriver.chrome.driver", "/home/netex/nightly_sanity/ui-scripts/chromedriver"); +// System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver"); + System.setProperty("webdriver.chrome.driver", "/home/netex/nightly_sanity/ui-scripts/chromedriver"); ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); -// options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless"); options.addArguments("--window-size=1920,1080"); driver = new ChromeDriver(options); @@ -70,17 +77,12 @@ public class LoginTest { } - public void launchPortal() { - driver2 = new ChromeDriver(); - driver2.get("https://wlan-ui.qa.lab.wlan.tip.build/"); - } - - public void launchSecondWindow() throws Exception { - Actions action = new Actions(driver); - String URL = driver.getCurrentUrl(); - action.sendKeys(Keys.chord(Keys.CONTROL, "n")).build().perform(); - driver.get(URL); - Thread.sleep(2000); + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); } public void login(String email, String password) { @@ -89,6 +91,8 @@ public class LoginTest { driver.findElement(By.xpath("//*[@id=\"login\"]/button/span")).click(); } + + public void checkHover(String box, int testId) throws Exception { try { String colour, colour2; @@ -132,10 +136,8 @@ public class LoginTest { } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -154,10 +156,8 @@ public class LoginTest { } Assert.assertEquals("Email field is not in focus", true, emailFocus); } catch (Exception E){ - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -204,10 +204,8 @@ public class LoginTest { } Assert.assertEquals("Login button is not in focus", true, confirmFocus); }catch (Exception E){ - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -237,10 +235,8 @@ public class LoginTest { } Assert.assertEquals("Password is still hidden", true, passwordTest2); } catch (Exception E){ - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -262,10 +258,8 @@ public class LoginTest { //Assert.assertEquals(expected, actual); } catch (Exception E){ - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -304,10 +298,8 @@ public class LoginTest { } Assert.assertEquals("No error message displayed", true, found); } catch (Exception E){ - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -322,10 +314,8 @@ public class LoginTest { } Assert.assertEquals("Email field not found", true, driver.findElement(By.id("login_email")).isDisplayed()); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -341,10 +331,8 @@ public class LoginTest { } Assert.assertEquals("Password field not found", true, driver.findElement(By.id("login_password")).isDisplayed()); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -357,10 +345,8 @@ public class LoginTest { } Assert.assertEquals("Incorrect URL", URL, "https://wlan-ui.qa.lab.wlan.tip.build/dashboard"); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -373,10 +359,8 @@ public class LoginTest { } Assert.assertEquals("Incorrect URL", URL, "https://wlan-ui.qa.lab.wlan.tip.build/login"); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } diff --git a/CICD_AP_CLOUDSDK/automationTests/NetworkTest.java b/CICD_AP_CLOUDSDK/automationTests/NetworkTest.java index 5cd60c78f..658a842b3 100644 --- a/CICD_AP_CLOUDSDK/automationTests/NetworkTest.java +++ b/CICD_AP_CLOUDSDK/automationTests/NetworkTest.java @@ -1,13 +1,18 @@ package automationTests; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.fail; +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.Calendar; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; import org.junit.Assert; import org.junit.BeforeClass; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; import org.junit.Test; import org.openqa.selenium.By; import org.openqa.selenium.Keys; @@ -18,26 +23,57 @@ import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.interactions.Actions; -class NetworkTest { +public class NetworkTest { WebDriver driver; static APIClient client; - //static ExtentTest test; + static long runId; +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; + @BeforeClass - public static void startTest() + public static void startTest() throws Exception { client = new APIClient("https://telecominfraproject.testrail.com"); client.setUser("syama.devi@connectus.ai"); - client.setPassword("Connectus123$"); + client.setPassword("Connect123$"); + + JSONArray c = (JSONArray) client.sendGet("get_runs/5"); + runId = new Long(0); + Calendar cal = Calendar.getInstance(); + //Months are indexed 0-11 so add 1 for current month + int month = cal.get(Calendar.MONTH) + 1; + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); + for (int a = 0; a < c.size(); a++) { + if (((JSONObject) c.get(a)).get("name").equals(date)) { + runId = (Long) ((JSONObject) c.get(a)).get("id"); + } + } } - + public void launchBrowser() { +// System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver"); System.setProperty("webdriver.chrome.driver", "/home/netex/nightly_sanity/ui-scripts/chromedriver"); ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); - options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless"); + options.addArguments("--window-size=1920,1080"); driver = new ChromeDriver(options); - driver.get("https://wlan-ui.qa.lab.wlan.tip.build"); + driver.get("https://wlan-ui.qa.lab.wlan.tip.build"); + } + + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); } void closeBrowser() { @@ -51,21 +87,34 @@ class NetworkTest { driver.findElement(By.xpath("//*[@id=\"login\"]/button/span")).click(); } - public void networkScreen() throws InterruptedException { - driver.findElement(By.linkText("Network")).click(); + public void networkScreen(int testId) throws Exception { + try { + driver.findElement(By.linkText("Network")).click(); + }catch (Exception E) { + failure(testId); + fail("Fail"); + } + } - public void loadAllProfiles() throws InterruptedException { - while (driver.findElements(By.xpath("//*[@id=\"root\"]/section/main/div/div/div[3]/button/span")).size() != 0) { - driver.findElement(By.xpath("/html/body/div/section/main/div/div/div[3]/button/span")).click(); - Thread.sleep(2000); + public void loadAllProfiles(int testId) throws Exception { + try { + while (driver.findElements(By.xpath("//*[@id=\"root\"]/section/main/div/div/div[3]/button/span")).size() != 0) { + driver.findElement(By.xpath("/html/body/div/section/main/div/div/div[3]/button/span")).click(); + Thread.sleep(2000); + } + }catch (Exception E) { + failure(testId); + fail("Fail"); } + } - public void addLocation(String loc) throws InterruptedException { + public void addLocation(String loc, int testId) throws Exception { try { driver.findElement(By.cssSelector(".ant-tree-node-content-wrapper:nth-child(3) > .ant-tree-title > span")).click(); } catch (Exception E) { + failure(testId); fail("Locations not found"); } @@ -75,6 +124,7 @@ class NetworkTest { try { driver.findElement(By.xpath("//span[contains(.,'Add Location')]")).click(); } catch (Exception E) { + failure(testId); fail("Add location button not found"); } @@ -88,25 +138,19 @@ class NetworkTest { browser.sendKeys(Keys.ENTER).perform(); Thread.sleep(2000); - if (driver.findElement(By.cssSelector(".ant-tree-treenode-switcher-close .ant-tree-title > span")).getText().equals(loc)) { - //pass - } else { - //System.out.print(driver.findElement(By.cssSelector(".ant-tree-treenode-switcher-close .ant-tree-title > span")).getText()); - - fail("Location could not be added"); + if (!driver.findElement(By.cssSelector(".ant-tree-treenode-switcher-close .ant-tree-title > span")).getText().equals(loc)) { + failure(testId); + fail("Fail"); } } - public void deleteLocation(String loc) throws InterruptedException { + public void deleteLocation(String loc, int testId) throws Exception { driver.findElement(By.cssSelector(".ant-tree-treenode-switcher-close .ant-tree-title > span")).click(); Thread.sleep(1000); driver.findElement(By.xpath("//span[contains(.,'Delete Location')]")).click(); Thread.sleep(2000); - if (driver.findElement(By.cssSelector(".ant-modal-body > p > i")).getText().equals(loc)) { - //pass - } else { - //System.out.print(driver.findElement(By.cssSelector(".ant-tree-treenode-switcher-close .ant-tree-title > span")).getText()); - + if (!driver.findElement(By.cssSelector(".ant-modal-body > p > i")).getText().equals(loc)) { + failure(testId); fail("Location not deleted"); } Actions browser = new Actions(driver); @@ -115,39 +159,30 @@ class NetworkTest { browser.sendKeys(Keys.TAB).perform(); browser.sendKeys(Keys.ENTER).perform(); Thread.sleep(2000); - } - //Verifies whether profile exists - public void verifyNetworkFields(boolean expected, String profile, String verifyType) { + //Verifies no field is blank in the column + public void verifyNetworkFields(boolean expected, String profile, int column, int testId) throws MalformedURLException, IOException, APIException { WebElement tbl = driver.findElement(By.xpath("//table")); List rows = tbl.findElements(By.tagName("tr")); //row iteration - for(int i=0; i cols = rows.get(i).findElements(By.tagName("td")); - - //column iteration - for(int j=0; j rows = tbl.findElements(By.tagName("tr")); boolean found = false; @@ -169,220 +204,78 @@ class NetworkTest { } if (!found) { - + failure(testId); fail("Network not found"); } //Assert.assertEquals(false, found); } - public void verifyDevice(String profile) { + public void verifyDevice(String profile, int testId) throws MalformedURLException, IOException, APIException { try { if (driver.findElement(By.cssSelector(".index-module__DeviceDetailCard___2CFDA.ant-card-bordered > div > div > div.index-module__leftWrapContent___2iZZo > p:nth-child(1)")).getText().equals(profile)) { //Pass } else { //System.out.print(driver.findElement(By.cssSelector(".index-module__DeviceDetailCard___2CFDA.ant-card-bordered > div > div > div.index-module__leftWrapContent___2iZZo > p:nth-child(1)")).getText()); - + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); fail("Wrong profile"); } } catch (Exception E) { - + failure(testId); fail("Profile title not found"); } } - public void changeAdvancedSettings() throws InterruptedException { - driver.findElement(By.cssSelector(".ant-collapse.ant-collapse-icon-position-right > div > div > span")).click(); - Thread.sleep(2000); - Actions cursor = new Actions(driver); - driver.findElement(By.xpath("//span[contains(.,'enabled')]")).click(); - cursor.sendKeys(Keys.ARROW_DOWN).perform(); - cursor.sendKeys(Keys.ENTER).perform(); - - for (int a = 0; a < 50; a++) { - cursor.sendKeys(Keys.TAB).perform(); - cursor.sendKeys(Keys.ENTER).perform(); - cursor.sendKeys(Keys.ARROW_DOWN).perform(); - cursor.sendKeys(Keys.ENTER).perform(); - } - - ////////driver.findElement(By.xpath("//button[contains(.,'Save')]")).click(); - - for (int a = 2; a < 15; a++) { - if(a == 5 || a== 7 || a == 10 || a == 11 || a == 12){ - // Will skip all these values. - continue; - } - - - for (int b = 1; b < 4; b++) { - String elementId = "//*[@id=\"root\"]/section/main/div/div/div[2]/div/form/div[4]/div/div[2]/div/div[" + a + "]/div[2]/div/div/div/div[" + b + "]/div/div/div/div/div/span[2]"; - WebElement box = driver.findElement(By.xpath(elementId)); - - if (a == 2 || a== 8 || a == 14) { - if (!box.getText().equals("disabled")) { - - fail("Advanced settings not saved"); - } - } else if (a == 3){ - if (!box.getText().equals("100")) { - - fail("Advanced settings not saved"); - } - } else if (a == 4 || a == 9){ - if (!box.getText().equals("enabled")) { - - fail("Advanced settings not saved"); - } - } else if (a == 6){ - if (!box.getText().equals("BGN")) { - - fail("Advanced settings not saved"); - } - } else if (a == 13){ - if (!box.getText().equals("20MHz")) { - - fail("Advanced settings not saved"); - } - } - - } - } - - if (!driver.findElement(By.id("rtsCtsThresholdis2dot4GHz")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("rtsCtsThresholdis5GHzL")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("rtsCtsThresholdis5GHzU")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxNumClientsis2dot4GHz")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxNumClientsis5GHzL")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxNumClientsis5GHzU")).getAttribute("value").equals("0")) { - - fail("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minSignalis2dot4GHz")).getAttribute("value").equals("-50")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minSignalis5GHzL")).getAttribute("value").equals("-50")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minSignalis5GHzU")).getAttribute("value").equals("-50")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdInDBis2dot4GHz")).getAttribute("value").equals("-10")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdInDBis5GHzL")).getAttribute("value").equals("-10")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdInDBis5GHzU")).getAttribute("value").equals("-10")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxApsis2dot4GHz")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxApsis5GHzL")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("maxApsis5GHzU")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdTimeInSecondsis2dot4GHz")).getAttribute("value").equals("120")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdTimeInSecondsis5GHzL")).getAttribute("value").equals("120")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("noiseFloorThresholdTimeInSecondsis5GHzU")).getAttribute("value").equals("120")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("dropInSnrPercentageis2dot4GHz")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("dropInSnrPercentageis5GHzL")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("dropInSnrPercentageis5GHzU")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minLoadFactoris2dot4GHz")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minLoadFactoris5GHzL")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } else if (!driver.findElement(By.id("minLoadFactoris5GHzU")).getAttribute("value").equals("0")) { - - fail ("Advanced settings not saved"); - } - } - public void verifyAdvancedSettings() throws InterruptedException { - driver.findElement(By.cssSelector(".ant-collapse.ant-collapse-icon-position-right > div > div > span")).click(); - Thread.sleep(2000); - - - for (int a = 7; a < 13; a++) { - if(a > 7 && a < 11){ - // Will skip all these values. - continue; - } - - - for (int b = 1; b < 4; b++) { - String elementId = "//*[@id=\"root\"]/section/main/div/div/div[2]/div/form/div[4]/div/div[2]/div/div[" + a + "]/div[2]/div/div/div/span[" + b + "]"; - WebElement box = driver.findElement(By.xpath(elementId)); - - if (box.getText().equals("")) { - if (a == 7) { - - fail("Mimo Mode field blank"); - } else if (a == 11) { - - fail("Active channel field blank"); - - } else if (a == 12) { - - fail("Backup channel field blank"); - } - - } - - } - } - - } - - - public void verifyAP(String profile) { + public void verifyAP(String profile, int testId) throws MalformedURLException, IOException, APIException { try { if (driver.findElement(By.cssSelector("#root > section > main > div > div > div.index-module__mainContent___1X1X6 > div > div.ant-card.ant-card-bordered.ant-card-contain-tabs > div.ant-card-head > div.ant-card-head-wrapper > div.ant-card-head-title > div > div > div:nth-child(1)")).getText().equals(profile)) { //Correct profile } else { - //System.out.print(driver.findElement(By.cssSelector(".index-module__DeviceDetailCard___2CFDA.ant-card-bordered > div > div > div.index-module__leftWrapContent___2iZZo > p:nth-child(1)")).getText()); - - fail("Wrong profile"); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + fail("Fail"); } } catch (Exception E) { - + failure(testId); fail("Profile title not found"); } } - public void refreshButton() throws InterruptedException { + public void verifyAPLocation(int testId) throws MalformedURLException, IOException, APIException { + try { + String location = driver.findElement(By.cssSelector(".ant-breadcrumb-link")).getText(); + + driver.findElement(By.cssSelector("[id^='rc-tabs-0-tab-location']")).click(); + Thread.sleep(2000); + String dropdownVerification = "[title^='"+location+"']"; + if (driver.findElements(By.cssSelector(dropdownVerification)).size()==0) { + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + fail("Wrong location"); + } + + } catch (Exception E) { + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + fail("Profile title not found"); + } + } + + public void refreshButton(int testId) throws Exception { try { driver.findElement(By.cssSelector("[title^='reload']")).click(); } catch (Exception E) { - + failure(testId); fail ("Reload button not visible"); } @@ -390,220 +283,670 @@ class NetworkTest { } - public void clientBlockedListButton() throws InterruptedException { + public void clientBlockedListButton(int testId) throws Exception { driver.findElement(By.xpath("//span[contains(.,'Blocked List')]")).click(); Thread.sleep(2000); String URL = driver.getCurrentUrl(); - Assert.assertEquals(URL, "https://wlan-ui.qa.lab.wlan.tip.build/system/blockedlist"); + + if (!URL.equals("https://wlan-ui.qa.lab.wlan.tip.build/system/blockedlist")) { + failure(testId); + + fail (); + } + //Assert.assertEquals(URL, "https://portal.dev1.netexperience.com/configure/system/blockedlist"); } - public void refreshNotificationAP() { + public void refreshNotificationAP(int testId) throws MalformedURLException, IOException, APIException { if (driver.findElement(By.cssSelector(".ant-notification-notice-description")).getText().equals("Access points reloaded.")) { } else { - + failure(testId); fail("Notification did not appear"); } } - public void refreshNotificationClientDevice() { + public void refreshNotificationClientDevice(int testId) throws MalformedURLException, IOException, APIException { if (driver.findElement(By.cssSelector(".ant-notification-notice-description")).getText().equals("Client devices reloaded.")) { } else { - + failure(testId); fail("Notification did not appear"); } } - public void clientDevicesScreen() { + public void clientDevicesScreen(int testId) throws MalformedURLException, IOException, APIException { try { driver.findElement(By.linkText("Client Devices")).click(); } catch (Exception E) { - + failure(testId); fail("Client Devices tab not visible"); } } + //C5603 @Test - void verifyFields() throws InterruptedException { - + public void verifyNameFields() throws Exception { + int testId = 5603; + Map data = new HashMap(); NetworkTest obj = new NetworkTest(); obj.launchBrowser(); obj.logIn(); Thread.sleep(3000); - obj.networkScreen(); + obj.networkScreen(testId); Thread.sleep(5000); - obj.loadAllProfiles(); - obj.verifyNetworkFields(false, "", "Network"); - obj.verifyNetworkFields(false, "N/A", "Network"); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 0, testId); + obj.verifyNetworkFields(false, "N/A", 0, testId); obj.closeBrowser(); - + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); } - - @Test - void viewAPTest() throws InterruptedException { + //C5604 + @Test + public void verifyAlarmFields() throws Exception { + int testId = 5604; + Map data = new HashMap(); NetworkTest obj = new NetworkTest(); obj.launchBrowser(); obj.logIn(); Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.findNetwork("AP_21P10C69703496_Rashad"); - Thread.sleep(3000); - obj.verifyAP("AP_21P10C69703496_Rashad"); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 1, testId); + obj.verifyNetworkFields(false, "N/A", 1, testId); obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5605 + @Test + public void verifyModelField() throws Exception { + int testId = 5605; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 2, testId); + obj.verifyNetworkFields(false, "N/A", 2, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5606 + @Test + public void verifyIPField() throws Exception { + int testId = 5606; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 3, testId); + obj.verifyNetworkFields(false, "N/A", 3, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5607 + @Test + public void verifyMACField() throws Exception { + int testId = 5607; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 4, testId); + obj.verifyNetworkFields(false, "N/A", 4, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5608 + @Test + public void verifyManufacturerField() throws Exception { + int testId = 5608; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 5, testId); + obj.verifyNetworkFields(false, "N/A", 5, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5609 + @Test + public void verifyFirmwareField() throws Exception { + int testId = 5609; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 6, testId); + obj.verifyNetworkFields(false, "N/A", 6, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5610 + @Test + public void verifyAssetIdField() throws Exception { + int testId = 5610; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 7, testId); + obj.verifyNetworkFields(false, "N/A", 7, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5611 + @Test + public void verifyUpTimeField() throws Exception { + int testId = 5611; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 8, testId); + obj.verifyNetworkFields(false, "N/A", 8, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5612 + @Test + public void verifyProfileField() throws Exception { + int testId = 5612; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 9, testId); + obj.verifyNetworkFields(false, "N/A", 9, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5613 + @Test + public void verifyChannelField() throws Exception { + int testId = 5613; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 10, testId); + obj.verifyNetworkFields(false, "N/A", 10, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5614 + @Test + public void verifyOccupancyField() throws Exception { + int testId = 5614; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 11, testId); + obj.verifyNetworkFields(false, "N/A", 11, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5615 + @Test + public void verifyNoiseFloorField() throws Exception { + int testId = 5615; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 12, testId); + obj.verifyNetworkFields(false, "N/A", 12, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5616 + @Test + public void verifyDevicesField() throws Exception { + int testId = 5616; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(testId); + Thread.sleep(5000); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 13, testId); + obj.verifyNetworkFields(false, "N/A", 13, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/" + testId, data); + } + + //C5618 + @Test + public void viewAPTest() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5618); + Thread.sleep(4500); + obj.findNetwork("Open_AP_21P10C69907629", 5618); + Thread.sleep(3000); + obj.verifyAP("Open_AP_21P10C69907629", 5618); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5618", data); } + //C5617 @Test - void refreshButtonTestAccessPoints() throws InterruptedException { - + public void refreshButtonTestAccessPoints() throws Exception { + Map data = new HashMap(); NetworkTest obj = new NetworkTest(); obj.launchBrowser(); obj.logIn(); Thread.sleep(3000); - obj.networkScreen(); + obj.networkScreen(5617); Thread.sleep(4500); - obj.refreshButton(); + obj.refreshButton(5617); Thread.sleep(2000); - obj.refreshNotificationAP(); - obj.closeBrowser(); - - } - @Test - void refreshButtonTestClientDevices() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); - Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.clientDevicesScreen(); - Thread.sleep(3500); - obj.refreshButton(); - Thread.sleep(2000); - obj.refreshNotificationClientDevice(); - obj.closeBrowser(); - - } - - @Test - void viewDeviceTest() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); - Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.clientDevicesScreen(); - Thread.sleep(3500); - obj.findNetwork("Mohammads-MBP"); - Thread.sleep(3000); - obj.verifyDevice("Mohammads-MBP"); - obj.closeBrowser(); - - } - @Test - void addLocationTest() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); - Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.addLocation("Test"); - Thread.sleep(3000); - obj.deleteLocation("Test"); - obj.closeBrowser(); - - } - @Test - void deleteLocationTest() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); - Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.addLocation("TestLoc"); - Thread.sleep(2000); - obj.deleteLocation("TestLoc"); - obj.closeBrowser(); - - } - @Test - void clientBlockedListTest() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); - Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.clientDevicesScreen(); - Thread.sleep(3500); - obj.clientBlockedListButton(); + obj.refreshNotificationAP(5617); obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5617", data); } + //C5590 @Test - void verifyDevicesFields() throws InterruptedException { + public void refreshButtonTestClientDevices() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5590); + Thread.sleep(4500); + obj.clientDevicesScreen(5590); + Thread.sleep(3500); + obj.refreshButton(5590); + Thread.sleep(2000); + obj.refreshNotificationClientDevice(5590); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5590", data); + } + + //C5592 + @Test + public void viewDeviceTest() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5592); + Thread.sleep(4500); + obj.clientDevicesScreen(5592); + Thread.sleep(3500); + obj.findNetwork("Mohammads-MBP", 5592); + Thread.sleep(3000); + obj.verifyDevice("Mohammads-MBP", 5592); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5592", data); + + } + + //C5619 + @Test + public void addLocationTest() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5619); + Thread.sleep(4500); + obj.addLocation("Test", 5619); + Thread.sleep(3000); + obj.deleteLocation("Test", 5619); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5619", data); + + } + + //C5620 + @Test + public void deleteLocationTest() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5620); + Thread.sleep(4500); + obj.addLocation("TestLoc", 5620); + Thread.sleep(2000); + obj.deleteLocation("TestLoc", 5620); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5620", data); + + } + + //C5591 + @Test + public void clientBlockedListTest() throws Exception { + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.networkScreen(5591); + Thread.sleep(4500); + obj.clientDevicesScreen(5591); + Thread.sleep(3500); + obj.clientBlockedListButton(5591); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5591", data); + + } + + //C5594 + @Test + public void verifyDevicesMACField() throws Exception { + int testId = 5594; + Map data = new HashMap(); NetworkTest obj = new NetworkTest(); obj.launchBrowser(); obj.logIn(); Thread.sleep(2500); - obj.networkScreen(); + obj.networkScreen(testId); Thread.sleep(4500); - obj.clientDevicesScreen(); + obj.clientDevicesScreen(testId); Thread.sleep(2500); - obj.loadAllProfiles(); - obj.verifyNetworkFields(false, "", "Device"); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 1, testId); obj.closeBrowser(); - + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5595 + @Test + public void verifyDevicesManufacturerField() throws Exception { + int testId = 5595; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 2, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5596 + @Test + public void verifyDevicesIPField() throws Exception { + int testId = 5596; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 3, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5597 + @Test + public void verifyDevicesHostNameField() throws Exception { + int testId = 5597; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 4, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5598 + @Test + public void verifyDevicesAPField() throws Exception { + int testId = 5598; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 5, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5599 + @Test + public void verifyDevicesSSIDField() throws Exception { + int testId = 5599; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 6, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5600 + @Test + public void verifyDevicesBandField() throws Exception { + int testId = 5600; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 7, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5601 + @Test + public void verifyDevicesSignalField() throws Exception { + int testId = 5601; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 8, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //C5602 + @Test + public void verifyDevicesStatusField() throws Exception { + int testId = 5602; + Map data = new HashMap(); + NetworkTest obj = new NetworkTest(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(2500); + obj.networkScreen(testId); + Thread.sleep(4500); + obj.clientDevicesScreen(testId); + Thread.sleep(2500); + obj.loadAllProfiles(testId); + obj.verifyNetworkFields(false, "", 9, testId); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); } + //C5623 @Test - void changeAdvancedSettingsTest() throws InterruptedException { - + public void verifyAPLocationTest() throws Exception { + Map data = new HashMap(); NetworkTest obj = new NetworkTest(); obj.launchBrowser(); obj.logIn(); Thread.sleep(3000); - obj.networkScreen(); + obj.networkScreen(5623); Thread.sleep(4500); - obj.findNetwork("Open_AP_21P10C68712730"); - Thread.sleep(4000); - obj.verifyAP("Open_AP_21P10C68712730"); - obj.changeAdvancedSettings(); - obj.closeBrowser(); - - } - - @Test - void verifyAdvancedSettingsTest() throws InterruptedException { - - NetworkTest obj = new NetworkTest(); - obj.launchBrowser(); - obj.logIn(); + obj.findNetwork("Open_AP_21P10C69907629", 5623); Thread.sleep(3000); - obj.networkScreen(); - Thread.sleep(4500); - obj.findNetwork("Open_AP_21P10C68712730"); - Thread.sleep(4000); - obj.verifyAP("Open_AP_21P10C68712730"); - obj.verifyAdvancedSettings(); + obj.verifyAPLocation(5623); obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5623", data); } - - } diff --git a/CICD_AP_CLOUDSDK/automationTests/ProfilesTest.java b/CICD_AP_CLOUDSDK/automationTests/ProfilesTest.java index 281f4cbc1..349204f91 100644 --- a/CICD_AP_CLOUDSDK/automationTests/ProfilesTest.java +++ b/CICD_AP_CLOUDSDK/automationTests/ProfilesTest.java @@ -37,20 +37,29 @@ public class ProfilesTest { static APIClient client; static long runId; + +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; @BeforeClass public static void startTest() throws Exception { client = new APIClient("https://telecominfraproject.testrail.com"); client.setUser("syama.devi@connectus.ai"); - client.setPassword("Connectus123$"); + client.setPassword("Connect123$"); JSONArray c = (JSONArray) client.sendGet("get_runs/5"); runId = new Long(0); Calendar cal = Calendar.getInstance(); //Months are indexed 0-11 so add 1 for current month int month = cal.get(Calendar.MONTH) + 1; - String date = "UI Automation Run - " + cal.get(Calendar.DATE) + "/" + month + "/" + cal.get(Calendar.YEAR); - + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); for (int a = 0; a < c.size(); a++) { if (((JSONObject) c.get(a)).get("name").equals(date)) { runId = (Long) ((JSONObject) c.get(a)).get("id"); @@ -80,6 +89,14 @@ public class ProfilesTest { driver.findElement(By.xpath("//*[@id=\"login\"]/button/span")).click(); } + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //Navigates to profiles tab public void profileScreen() throws Exception { driver.findElement(By.linkText("Profiles")).click(); @@ -89,13 +106,10 @@ public class ProfilesTest { try { while (driver.findElements(By.xpath("//*[@id=\"root\"]/section/main/div/div/div[3]/button/span")).size() != 0) { driver.findElement(By.xpath("/html/body/div/section/main/div/div/div[3]/button/span")).click(); - Thread.sleep(2000); + Thread.sleep(1400); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -122,18 +136,15 @@ public class ProfilesTest { } } if (expected != found && expected == true) { - + failure(testId); fail("Profile not found."); } else if (expected != found && expected == false){ - + failure(testId); fail("Profile unexpectedly found in the list."); } //Assert.assertEquals(expected, found); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -162,17 +173,12 @@ public class ProfilesTest { } } if (!found) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Profile not found."); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -182,17 +188,11 @@ public class ProfilesTest { //Correct profile } else { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Incorrect Profile selected"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("No title found for profile"); } } @@ -209,10 +209,8 @@ public class ProfilesTest { fail("Popup displays incorrect text"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -227,10 +225,8 @@ public class ProfilesTest { driver.navigate().refresh(); Thread.sleep(3000); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -244,10 +240,8 @@ public class ProfilesTest { driver.navigate().refresh(); Thread.sleep(1500); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -260,10 +254,7 @@ public class ProfilesTest { String URL = driver.getCurrentUrl(); Assert.assertEquals("Incorrect URL", URL, "https://wlan-ui.qa.lab.wlan.tip.build/addprofile"); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -276,10 +267,7 @@ public class ProfilesTest { driver.findElement(By.xpath("//*[@id=\"root\"]/section/main/div/div/div[1]/div/button")).click(); Thread.sleep(1000); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -292,10 +280,7 @@ public class ProfilesTest { //pass } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail("Notification not found"); } @@ -307,10 +292,8 @@ public class ProfilesTest { driver.findElement(By.xpath("//*[@id=\"name\"]")).sendKeys("AutomationTest Profile"); driver.findElement(By.xpath("//*[@id=\"ssid\"]")).sendKeys("Automation Test SSID"); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -319,10 +302,8 @@ public class ProfilesTest { try { driver.findElement(By.xpath("//*[@id=\"root\"]/section/main/div/div/div/div/button/span")).click(); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -334,10 +315,8 @@ public class ProfilesTest { driver.findElement(By.cssSelector("body > div:nth-child(9) > div > div.ant-modal-wrap > div > div.ant-modal-content > " + "div.ant-modal-footer > div > button.ant-btn.index-module__Button___3SCd4.ant-btn-primary")).click(); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -354,10 +333,8 @@ public class ProfilesTest { fail("No options for captive portal found"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -373,14 +350,12 @@ public class ProfilesTest { Thread.sleep(3000); if (driver.findElements(By.className("ant-table-empty")).size()!=0) { - + failure(testId); fail("Table not displaying SSIDs"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -388,28 +363,20 @@ public class ProfilesTest { public void bandwidthDetails(int testId) throws Exception { try { - Map data = new HashMap(); WebElement bandwidth = driver.findElement(By.xpath("//*[@id=\"bandwidthLimitDown\"]")); //Actions action = new Actions(driver); bandwidth.sendKeys(Keys.BACK_SPACE); bandwidth.sendKeys("123"); Thread.sleep(500); - //Looks for field and error text is verified. If field is not found the exception is caught. try { - if (driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) + if (!driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) .getText().equals("Downstream bandwidth limit can be a number between 0 and 100.")){ - //No further steps needed - } else { - System.out.print(driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) - .getText()); - + failure(testId); fail(); } } catch (Exception E) { - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -420,22 +387,17 @@ public class ProfilesTest { bandwidth.sendKeys("-10"); Thread.sleep(500); - //Looks for field and text is verified. If field is not found the exception is caught. + try { - if (driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) + if (!driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) .getText().equals("Downstream bandwidth limit can be a number between 0 and 100.")){ - //No further steps needed - } else { - System.out.print(driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) - .getText()); - + failure(testId); fail(); } } catch (Exception E) { - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); - fail("Bandwidths outside the desired range are accepted"); + failure(testId); + fail(); + } bandwidth.sendKeys(Keys.BACK_SPACE); @@ -445,17 +407,16 @@ public class ProfilesTest { bandwidth.sendKeys("10"); Thread.sleep(500); - //Looks for field and text is verified. If field is not found the exception is caught. + if (driver.findElements(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) .size()!=0){ + failure(testId); + fail(); - fail("Field not found"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -484,15 +445,14 @@ public class ProfilesTest { found = false; } } catch (Exception E) { + failure(testId); + fail(); - fail("Section not found"); } Assert.assertEquals(true, found); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -508,29 +468,24 @@ public class ProfilesTest { cursor.sendKeys(Keys.ENTER).perform(); Thread.sleep(1500); - boolean found = true; try { if (!driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-head > div > div")).getText().equals("LAN and Services")) { - found = false; + failure(testId); + fail(); } else if (!driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(2) > div.ant-card-head > div > div")).getText().equals("Wireless Networks (SSIDs) Enabled on This Profile")) { - found = false; + failure(testId); + fail(); } } catch (Exception E) { - found = false; - - fail("Section not found"); + failure(testId); + fail(); } - if (!found) { - - fail("Section Not Found"); - } + //Assert.assertEquals(true, found); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -818,7 +773,6 @@ public class ProfilesTest { obj.findProfile("ECW5410 Automation",4815); Thread.sleep(5000); obj.verifyProfile("ECW5410 Automation",4815); - //obj.addProfileButton(); obj.closeBrowser(); data.put("status_id", new Integer(1)); data.put("comment", "This test worked fine!"); diff --git a/CICD_AP_CLOUDSDK/automationTests/SystemTests.java b/CICD_AP_CLOUDSDK/automationTests/SystemTests.java index af8666210..9b2829761 100644 --- a/CICD_AP_CLOUDSDK/automationTests/SystemTests.java +++ b/CICD_AP_CLOUDSDK/automationTests/SystemTests.java @@ -31,25 +31,33 @@ import org.openqa.selenium.interactions.Actions; public class SystemTests { WebDriver driver; - static APIClient client; static long runId; +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; @BeforeClass public static void startTest() throws Exception { +// client.setUser(trUser); +// client.setPassword(trPwd); client = new APIClient("https://telecominfraproject.testrail.com"); client.setUser("syama.devi@connectus.ai"); - client.setPassword("Connectus123$"); + client.setPassword("Connect123$"); - JSONArray c = (JSONArray) client.sendGet("get_runs/5"); runId = new Long(0); Calendar cal = Calendar.getInstance(); //Months are indexed 0-11 so add 1 for current month int month = cal.get(Calendar.MONTH) + 1; - String date = "UI Automation Run - " + cal.get(Calendar.DATE) + "/" + month + "/" + cal.get(Calendar.YEAR); - + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); for (int a = 0; a < c.size(); a++) { if (((JSONObject) c.get(a)).get("name").equals(date)) { runId = (Long) ((JSONObject) c.get(a)).get("id"); @@ -59,9 +67,9 @@ public class SystemTests { public void launchBrowser() { System.setProperty("webdriver.chrome.driver", "/home/netex/nightly_sanity/ui-scripts/chromedriver"); +// System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver"); ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); - //options.addArguments("--disable-dev-shm-usage"); options.addArguments("--headless"); options.addArguments("--window-size=1920,1080"); driver = new ChromeDriver(options); @@ -72,6 +80,14 @@ public class SystemTests { driver.close(); } + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + //Log into the CloudSDK portal public void logIn() { driver.findElement(By.id("login_email")).sendKeys("support@example.com"); @@ -84,10 +100,8 @@ public class SystemTests { try { driver.findElement(By.linkText("System")).click(); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -100,22 +114,90 @@ public class SystemTests { cursor.sendKeys(Keys.ENTER).build().perform(); Thread.sleep(1000); - boolean found = false; - if (driver.findElement(By.cssSelector(".ant-notification-notice-description")).getText().equals("No matching manufacturer found for OUI")) { - found = true; + + if (!driver.findElement(By.cssSelector(".ant-notification-notice-description")).getText().equals("No matching manufacturer found for OUI")) { + failure(testId); + fail(); + } - if (!found) { -// test.log(LogStatus.FAIL, "Error message not displayed"); - } - Assert.assertEquals("Error message not displayed", true, found); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); + } + } + + public void ouiFormats(int testId) throws Exception { + Actions cursor = new Actions(driver); + WebElement oui = driver.findElement(By.xpath("//*[@id=\"oui\"]")); + cursor.sendKeys(oui, "88:12:4E").build().perform(); + cursor.sendKeys(Keys.ENTER).build().perform(); + Thread.sleep(1000); + + boolean found = false; + if (driver.findElements(By.cssSelector(".ant-notification-notice-description")).size()>0) { + found = true; + } + if (found) { + failure(testId); + fail(); + } + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + + cursor.sendKeys(oui, "88124E").build().perform(); + cursor.sendKeys(Keys.ENTER).build().perform(); + Thread.sleep(1000); + + if (driver.findElements(By.cssSelector(".ant-notification-notice-description")).size()>0) { + found = true; + } + if (found) { + failure(testId); fail(); } + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + cursor.sendKeys(Keys.BACK_SPACE).perform(); + + cursor.sendKeys(oui, "88-12-4E").build().perform(); + cursor.sendKeys(Keys.ENTER).build().perform(); + Thread.sleep(2000); + + if (driver.findElements(By.cssSelector(".ant-notification-notice-description")).size()>0) { + failure(testId); + fail(); + } + } + + public void ouiLength(int testId) throws Exception { + try { + Actions cursor = new Actions(driver); + WebElement oui = driver.findElement(By.xpath("//*[@id=\"oui\"]")); + cursor.sendKeys(oui, "123456789").build().perform(); + cursor.sendKeys(Keys.ENTER).build().perform(); + Thread.sleep(3000); + + if (oui.getAttribute("value").length()>8) { + failure(testId); + fail(); + } + + } catch (Exception E) { + failure(testId); + fail(); + } } public void addVersion(int testId) throws Exception { @@ -129,10 +211,8 @@ public class SystemTests { driver.findElement(By.cssSelector(".ant-btn.index-module__Button___3SCd4.ant-btn-primary")).click(); Thread.sleep(1000); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -151,18 +231,15 @@ public class SystemTests { if (driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div.ant-col.ant-col-15.ant-form-item-control > div.ant-form-item-explain > div")).getText().equals("Please input your Version Name")) { //error message found } else { - + failure(testId); fail("Incorrect error message displayed"); } } catch (Exception E) { - + failure(testId); fail("Error message not displayed"); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -173,7 +250,7 @@ public class SystemTests { try { driver.findElement(By.xpath("//span[contains(.,'Add Client')]")).click(); } catch (Exception E) { - + failure(testId); fail("Add Client button not found"); } @@ -185,10 +262,7 @@ public class SystemTests { browser.sendKeys(Keys.TAB).perform(); browser.sendKeys(Keys.ENTER).perform(); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -205,17 +279,13 @@ public class SystemTests { // driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-col.ant-col-12.ant-form-item-control > div.ant-form-item-explain > div")) // .click(); try { - if (driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-col.ant-col-12.ant-form-item-control > div.ant-form-item-explain > div")) + if (!driver.findElement(By.cssSelector("body > div:nth-child(8) > div > div.ant-modal-wrap > div > div.ant-modal-content > div.ant-modal-body > form > div > div.ant-col.ant-col-12.ant-form-item-control > div.ant-form-item-explain > div")) .getText().equals("Please enter a valid MAC Address.")){ - //No further steps needed - } else { -// System.out.print(driver.findElement(By.cssSelector("#root > section > main > div > div > form > div.index-module__ProfilePage___OaO8O > div:nth-child(1) > div.ant-card-body > div:nth-child(3) > div.ant-col.ant-col-12.ant-form-item-control > div > div > div > div.ant-row.ant-form-item.ant-form-item-with-help.ant-form-item-has-error > div > div.ant-form-item-explain > div")) -// .getText()); - + failure(testId); fail("Incorrect error message displayed"); } } catch (Exception E) { - + failure(testId); fail("Error message not displayed"); } @@ -223,10 +293,7 @@ public class SystemTests { browser.sendKeys(Keys.TAB).perform(); browser.sendKeys(Keys.ENTER).perform(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -249,10 +316,7 @@ public class SystemTests { browser.sendKeys(Keys.TAB).perform(); browser.sendKeys(Keys.ENTER).perform(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -288,10 +352,7 @@ public class SystemTests { fail("Version unexpectedly found in the list."); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -324,10 +385,7 @@ public class SystemTests { fail("Version unexpectedly found in the list."); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -359,10 +417,7 @@ public class SystemTests { } //Assert.assertEquals(expected, found); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -393,10 +448,8 @@ public class SystemTests { fail("Mac Address unexpectedly found in the list."); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -420,10 +473,8 @@ public class SystemTests { browse.sendKeys(Keys.TAB).perform(); browse.sendKeys(Keys.ENTER).perform(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } @@ -434,10 +485,7 @@ public class SystemTests { driver.findElement(By.cssSelector("[title^='edit-model-TEST']")).click(); Thread.sleep(2000); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -457,10 +505,8 @@ public class SystemTests { //driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/button[2]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -473,7 +519,7 @@ public class SystemTests { if (!dropdown.getAttribute("title").equals("Toronto")){ - //fail("Incorrect Locations displayed"); + fail("Incorrect Locations displayed"); } browser.sendKeys(dropdown, Keys.ARROW_DOWN).perform(); @@ -483,7 +529,7 @@ public class SystemTests { if (!dropdown.getAttribute("title").equals("FirstFloor")){ - //fail("Incorrect Locations displayed"); + fail("Incorrect Locations displayed"); } browser.sendKeys(Keys.ARROW_DOWN).perform(); @@ -493,7 +539,7 @@ public class SystemTests { if (!dropdown.getAttribute("title").equals("TipBuilding")){ - //fail("Incorrect Locations displayed"); + fail("Incorrect Locations displayed"); } browser.sendKeys(Keys.ARROW_DOWN).perform(); @@ -503,13 +549,10 @@ public class SystemTests { if (!dropdown.getAttribute("title").equals("Ottawa")){ - //fail("Incorrect Locations displayed"); + fail("Incorrect Locations displayed"); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -525,20 +568,18 @@ public class SystemTests { } else if (driver.findElement(By.xpath("//*[@id=\"rcDialogTitle2\"]")).getText().equals("Are you sure?")){ //Will have this Id when version edit button has been clicked prior } else { - + failure(testId); fail("Confirmation not found"); } } catch (Exception E) { - + failure(testId); fail("Confirmation not found"); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); + } } @@ -555,11 +596,9 @@ public class SystemTests { Thread.sleep(1000); driver.navigate().refresh(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); + } } @@ -574,19 +613,16 @@ public class SystemTests { } else if (driver.findElement(By.xpath("//*[@id=\"rcDialogTitle2\"]")).getText().equals("Are you sure?")){ //Will have this Id when version edit button has been clicked prior } else { - + failure(testId); fail("Confirmation not found"); } } catch (Exception E) { - + failure(testId); fail("Confirmation not found"); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -598,10 +634,7 @@ public class SystemTests { driver.findElement(By.cssSelector("[title^='edit-firmware-TEST']")).click(); Thread.sleep(2000); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -613,10 +646,7 @@ public class SystemTests { driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[2]/div[2]/div/div/input")).sendKeys("123"); driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/button[2]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -627,10 +657,7 @@ public class SystemTests { driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div[2]/form/div[2]/div[2]/div/div/input")).sendKeys("123"); driver.findElement(By.xpath("/html/body/div[4]/div/div[2]/div/div[2]/div[3]/div/button[1]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -648,10 +675,7 @@ public class SystemTests { Thread.sleep(1000); driver.navigate().refresh(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } @@ -668,10 +692,7 @@ public class SystemTests { fail("Set manufacturer data section title incorrect"); } }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } //Assert.assertEquals(true, found); @@ -681,26 +702,20 @@ public class SystemTests { if (enabled) { try { if (!driver.findElement(By.cssSelector("#root > section > main > div:nth-child(2) > form > div.index-module__Content___2GmAx > div:nth-child(1) > div.ant-card-head > div > div")).getText().equals("Target Location")) { - + failure(testId); fail("Target Location title incorrect"); } else if (!driver.findElement(By.cssSelector("#root > section > main > div:nth-child(2) > form > div.index-module__Content___2GmAx > div:nth-child(2) > div.ant-card-head > div > div.ant-card-head-title")).getText().equals("Target Equipment Profiles")) { fail("Target equipment profiles title incorrect"); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); } } else { if (driver.findElements(By.cssSelector("#root > section > main > div:nth-child(2) > form > div.index-module__Content___2GmAx > div:nth-child(1) > div.ant-card-head > div > div")).size()!=0) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); fail(); @@ -716,10 +731,8 @@ public class SystemTests { try { driver.findElement(By.xpath("//*[@id=\"rc-tabs-0-tab-firmware\"]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -728,10 +741,8 @@ public class SystemTests { try { driver.findElement(By.xpath("//*[@id=\"rc-tabs-0-tab-autoprovision\"]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -740,10 +751,8 @@ public class SystemTests { try { driver.findElement(By.xpath("//*[@id=\"rc-tabs-0-tab-blockedlist\"]")).click(); }catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -758,23 +767,16 @@ public class SystemTests { } else if (driver.findElement(By.xpath("//*[@id=\"rcDialogTitle2\"]")).getText().equals("Are you sure?")){ //Will have this Id when version edit button has been clicked prior } else { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); - fail("Confirmation not found"); + failure(testId); + fail(); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } } @@ -791,12 +793,85 @@ public class SystemTests { Thread.sleep(1000); driver.navigate().refresh(); } catch (Exception E) { - Map data = new HashMap(); - data.put("status_id", new Integer(5)); - data.put("comment", "Fail"); - JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + failure(testId); + fail(); } + } + + public void uniqueVersion(int testId) throws MalformedURLException, IOException, APIException { + + try { + WebElement tbl = driver.findElement(By.cssSelector("#root > section > main > div:nth-child(2) > div:nth-child(2) > div > div > div > div > div > table")); + List rows = tbl.findElements(By.tagName("tr")); + List ids = new ArrayList(); + + boolean found = false; + //row iteration + for(int i=1; i cols = rows.get(i).findElements(By.tagName("td")); + + if (ids.contains(cols.get(0).getText())) { + failure(testId); + fail(); + } else { +// System.out.print(cols.get(0).getText()); + ids.add(cols.get(0).getText()); + } + + } + + }catch (Exception E) { + failure(testId); + fail(); + } + } + + public List listOfVersions(int table, int testId) throws MalformedURLException, IOException, APIException { + List ids = new ArrayList(); + try { + WebElement tbl; + if (table == 1) { + tbl = driver.findElement(By.xpath("//table")); + } else { + tbl = driver.findElement(By.xpath("//*[@id=\"root\"]/section/main/div[2]/div[4]/div/div/div/div/div/table")); + } + + List rows = tbl.findElements(By.tagName("tr")); + //List ids = new ArrayList(); + + boolean found = false; + //row iteration + for(int i=1; i cols = rows.get(i).findElements(By.tagName("td")); + + if (!ids.contains(cols.get(0).getText())) { + ids.add(cols.get(0).getText()); + } + } + + return ids; + + }catch (Exception E) { + failure(testId); + fail(); + } + return ids; + } + + public int addModelAndClickDropdown(int testId) throws Exception { + driver.findElement(By.xpath("//span[contains(.,'Add Model Target Version')]")).click(); + Thread.sleep(1000); + Actions browse = new Actions(driver); + Thread.sleep(1000); + browse.sendKeys(Keys.TAB).perform(); + browse.sendKeys(Keys.TAB).perform(); + + browse.sendKeys(Keys.ENTER).perform(); + List versions = driver.findElements(By.cssSelector(".ant-select-item.ant-select-item-option")); + browse.sendKeys(Keys.ESCAPE).perform(); + System.out.print(versions.size()); + return versions.size(); } @@ -835,6 +910,38 @@ public class SystemTests { JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5036", data); } + //C5639 + @Test + public void ouiLengthTest() throws Exception { + Map data = new HashMap(); + SystemTests obj = new SystemTests(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.systemScreen(5639); + Thread.sleep(2500); + obj.ouiLength(5639); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5639", data); + } + //C5640 + @Test + public void ouiFormatTest() throws Exception { + Map data = new HashMap(); + SystemTests obj = new SystemTests(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.systemScreen(5640); + Thread.sleep(2500); + obj.ouiFormats(5640); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5640", data); + } //C5040 @Test public void createVersionTest() throws Exception { @@ -947,7 +1054,7 @@ public class SystemTests { Thread.sleep(1500); obj.findVersion(true, "TEST123", 5056); obj.deleteVersion(5056); - Thread.sleep(2000); + Thread.sleep(6000); obj.closeBrowser(); data.put("status_id", new Integer(1)); data.put("comment", "This test worked fine!"); @@ -1226,5 +1333,53 @@ public class SystemTests { data.put("comment", "This test worked fine!"); JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5062", data); } + + //C5638 + @Test + public void uniqueFieldsTest() throws Exception { + Map data = new HashMap(); + SystemTests obj = new SystemTests(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.systemScreen(5638); + Thread.sleep(4500); + obj.firmwareScreen(5638); + Thread.sleep(1000); + obj.uniqueVersion(5638); + Thread.sleep(2000); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/5638", data); + } + + //C5637 + @Test + public void versionsAvailableTest() throws Exception { + int testId = 5637; + Map data = new HashMap(); + SystemTests obj = new SystemTests(); + obj.launchBrowser(); + obj.logIn(); + Thread.sleep(3000); + obj.systemScreen(testId); + Thread.sleep(2500); + obj.firmwareScreen(testId); + Thread.sleep(1000); + List ids = obj.listOfVersions(2, testId); + int dropdownOptions = obj.addModelAndClickDropdown(testId); + List modTarg = obj.listOfVersions(1, testId); + int expected = ids.size() - modTarg.size(); + if (dropdownOptions!= expected) { + fail(); + } + + Thread.sleep(2000); + obj.closeBrowser(); + data.put("status_id", new Integer(1)); + data.put("comment", "This test worked fine!"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } } diff --git a/CICD_AP_CLOUDSDK/automationTests/UsersTest.java b/CICD_AP_CLOUDSDK/automationTests/UsersTest.java new file mode 100644 index 000000000..715e8610e --- /dev/null +++ b/CICD_AP_CLOUDSDK/automationTests/UsersTest.java @@ -0,0 +1,470 @@ +package automationTests; + +import static org.junit.jupiter.api.Assertions.*; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.util.Calendar; +import java.util.HashMap; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.Test; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.openqa.selenium.By; +import org.openqa.selenium.Keys; +import org.openqa.selenium.WebDriver; +import org.openqa.selenium.WebElement; +import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; +import org.openqa.selenium.interactions.Actions; +import org.json.simple.JSONArray; +import org.json.simple.JSONObject; +import org.json.simple.JSONValue; + +import java.util.Map; + +public class UsersTest{ + WebDriver driver; + static APIClient client; + static long runId; + +// static String Url = System.getenv("CLOUD_SDK_URL"); +// static String trUser = System.getenv("TR_USER"); +// static String trPwd = System.getenv("TR_PWD"); +// static String cloudsdkUser = "support@example.com"; +// static String cloudsdkPwd="support"; + @BeforeClass + public static void startTest() throws Exception + { + client = new APIClient("https://telecominfraproject.testrail.com"); + client.setUser("syama.devi@connectus.ai"); + client.setPassword("Connect123$"); + JSONArray c = (JSONArray) client.sendGet("get_runs/5"); + runId = new Long(0); + + Calendar cal = Calendar.getInstance(); + //Months are indexed 0-11 so add 1 for current month + int month = cal.get(Calendar.MONTH) + 1; + String day = Integer.toString(cal.get(Calendar.DATE)); + if (day.length()<2) { + day = "0"+day; + } + String date = "UI Automation Run - " + day + "/" + month + "/" + cal.get(Calendar.YEAR); + + for (int a = 0; a < c.size(); a++) { + if (((JSONObject) c.get(a)).get("name").equals(date)) { + runId = (Long) ((JSONObject) c.get(a)).get("id"); + } + } + } + + public void launchBrowser() { + System.setProperty("webdriver.chrome.driver", "/home/netex/nightly_sanity/ui-scripts/chromedriver"); +// System.setProperty("webdriver.chrome.driver", "/Users/mohammadrahman/Downloads/chromedriver"); + ChromeOptions options = new ChromeOptions(); + options.addArguments("--no-sandbox"); + options.addArguments("--headless"); + options.addArguments("--window-size=1920,1080"); + driver = new ChromeDriver(options); + driver.get("https://wlan-ui.qa.lab.wlan.tip.build"); + } + + void closeBrowser() { + driver.close(); + } + + public void logIn() { + driver.findElement(By.id("login_email")).sendKeys("support@example.com"); + driver.findElement(By.id("login_password")).sendKeys("support"); + driver.findElement(By.xpath("//*[@id=\"login\"]/button/span")).click(); + } + + public void failure(int testId) throws MalformedURLException, IOException, APIException { + driver.close(); + Map data = new HashMap(); + data.put("status_id", new Integer(5)); + data.put("comment", "Fail"); + JSONObject r = (JSONObject) client.sendPost("add_result_for_case/"+runId+"/"+testId, data); + } + + public void accountsScreen(int testId) throws Exception { + try { + driver.findElement(By.linkText("Users")).click(); + } catch (Exception E) { + failure(testId); + fail("Fail"); + } + + } + + public void addAccountButton(int testId) throws MalformedURLException, IOException, APIException { + try { + Actions act = new Actions(driver); + act.moveToElement(driver.findElement(By.cssSelector("[title^='addaccount']"))).click().perform(); + } catch (Exception E) { + failure(testId); + fail("Fail"); + } + + } + + public void verifyAddAccountPopup(int testId) throws MalformedURLException, IOException, APIException { + Map data = new HashMap(); + try { + if (driver.findElement(By.id("rcDialogTitle0")).getText().equals("Add User")) { + //pass + } else { + + failure(testId); + fail(); + } + } catch (Exception E) { + failure(testId); + fail("Fail"); + } + } + + public void addAccount(String account, String password, String confirmPassword, int testId) throws MalformedURLException, IOException, APIException { + try { + addAccountButton(testId); + Actions browser = new Actions(driver); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(account).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(password).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(confirmPassword).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(Keys.TAB).perform(); + browser.sendKeys(Keys.ENTER).perform(); + } catch (Exception E) { + failure(testId); + fail("Fail"); + } + + } + + public void blankEmailWarning(int testId) throws Exception { + try { + if (driver.findElement(By.cssSelector("[role^='alert']")).getText().equals("Please input your e-mail")) { + //pass + } else { + + failure(testId); + fail("Incorrect warning displayed"); + } + } catch (Exception E) { + failure(testId); + fail("No warning displayed"); + } + } + + public void invalidPasswordsWarning(int testId) throws Exception { + try { + if (driver.findElement(By.cssSelector("[role^='alert']")).getText().equals("The two passwords do not match")) { + //pass + } else { + + failure(testId); + fail("Incorrect warning displayed"); + } + } catch (Exception E) { + failure(testId); + fail("No warning displayed"); + } + } + + public void invalidEmailWarning(int testId) throws Exception { + try { + if (driver.findElement(By.cssSelector("[role^='alert']")).getText().equals("The input is not a valid e-mail")) { + //pass + } else { + + failure(testId); + fail("Incorrect error displayed"); + } + } catch (Exception E) { + failure(testId); + fail("No error displayed"); + } + } + + public void editAccount(String oldName, String newName, int testId) throws Exception { + try { + WebElement tbl = driver.findElement(By.xpath("//table")); + List rows = tbl.findElements(By.tagName("tr")); + boolean found = false; + //row iteration + breakP: + for(int i=0; i cols = rows.get(i).findElements(By.tagName("td")); + + //column iteration + for(int j=0; j rows = tbl.findElements(By.tagName("tr")); + boolean found = false; + //row iteration + breakP: + for(int i=0; i cols = rows.get(i).findElements(By.tagName("td")); + + //column iteration + for(int j=0; j rows = tbl.findElements(By.tagName("tr")); + boolean found = false; + //row iteration + for(int i=0; i cols = rows.get(i).findElements(By.tagName("td")); + + //column iteration + for(int j=0; j 0) { System.out.println("Tests failed.");