Aharoni, Pavel (pa0916) | ca3cb01 | 2018-10-22 15:29:57 +0300 | [diff] [blame^] | 1 | /*-
|
| 2 | * ============LICENSE_START=======================================================
|
| 3 | * OSAM
|
| 4 | * ================================================================================
|
| 5 | * Copyright (C) 2018 AT&T
|
| 6 | * ================================================================================
|
| 7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 8 | * you may not use this file except in compliance with the License.
|
| 9 | * You may obtain a copy of the License at
|
| 10 | *
|
| 11 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 12 | *
|
| 13 | * Unless required by applicable law or agreed to in writing, software
|
| 14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 16 | * See the License for the specific language governing permissions and
|
| 17 | * limitations under the License.
|
| 18 | * ============LICENSE_END=========================================================
|
| 19 | */
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 | package org.onap.ecomp.vid.selenium;
|
| 24 |
|
| 25 | import java.io.FileInputStream;
|
| 26 | import java.io.IOException;
|
| 27 | import java.io.InputStream;
|
| 28 | import java.util.List;
|
| 29 | import java.util.Properties;
|
| 30 | import java.util.concurrent.TimeUnit;
|
| 31 |
|
| 32 | import org.apache.log4j.Logger;
|
| 33 | import org.openqa.selenium.By;
|
| 34 | import org.openqa.selenium.WebDriver;
|
| 35 | import org.openqa.selenium.WebElement;
|
| 36 | import org.openqa.selenium.firefox.FirefoxDriver;
|
| 37 | import org.openqa.selenium.support.ui.Select;
|
| 38 | import org.testng.Assert;
|
| 39 | import org.testng.annotations.BeforeTest;
|
| 40 | import org.testng.annotations.Test;
|
| 41 |
|
| 42 | @Test(enabled=false)
|
| 43 | public class LogOutLeftPane {
|
| 44 |
|
| 45 | WebElement loginButton;
|
| 46 |
|
| 47 | /** The login. */
|
| 48 | WebElement login;
|
| 49 |
|
| 50 | /** The pwd. */
|
| 51 | WebElement pwd;
|
| 52 |
|
| 53 | /** The log. */
|
| 54 | Logger log;
|
| 55 |
|
| 56 | /** The errormessage. */
|
| 57 | WebElement errormessage;
|
| 58 |
|
| 59 | /** The driver. */
|
| 60 | WebDriver driver=new FirefoxDriver();
|
| 61 |
|
| 62 |
|
| 63 | /** The config prop. */
|
| 64 | private final Properties configProp = new Properties();
|
| 65 |
|
| 66 |
|
| 67 | /**
|
| 68 | * Instantiates a new log out left pane.
|
| 69 | */
|
| 70 | private LogOutLeftPane() {
|
| 71 | // TODO Auto-generated constructor stub
|
| 72 | //
|
| 73 | try{
|
| 74 | // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
|
| 75 | //FileInputStream input1 = new FileInputStream("objectmap.properties");
|
| 76 |
|
| 77 | InputStream input =new FileInputStream("objectconfig.properties");
|
| 78 | System.out.println("Read all properties from file");
|
| 79 | configProp.load(input);
|
| 80 | System.out.println("Read all properties from file completed");
|
| 81 | }
|
| 82 | catch(IOException e) {
|
| 83 |
|
| 84 | e.printStackTrace();
|
| 85 | }
|
| 86 | }
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 | /**
|
| 92 | * Do before test.
|
| 93 | */
|
| 94 | // TODO Auto-generated method stub
|
| 95 | @BeforeTest
|
| 96 | public void doBeforeTest()
|
| 97 | {
|
| 98 | //WebDriver driver=new FirefoxDriver();
|
| 99 |
|
| 100 | log = Logger.getLogger(LogOutLeftPane.class.getName());
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 | // Get url
|
| 105 | driver.get("http://vid.onap.org:9080/vid/login_external.htm");
|
| 106 | driver.manage().window().maximize();
|
| 107 |
|
| 108 |
|
| 109 | login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
|
| 110 | pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
|
| 111 | loginButton = driver.findElement(By.id("loginBtn"));
|
| 112 | }
|
| 113 |
|
| 114 |
|
| 115 | /**
|
| 116 | * Expand collapse panel.
|
| 117 | *
|
| 118 | * @throws InterruptedException the interrupted exception
|
| 119 | */
|
| 120 | @Test(priority=1)
|
| 121 | public void expandCollapsePanel() throws InterruptedException
|
| 122 | {
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 | login.clear();
|
| 127 | login.sendKeys("su");
|
| 128 | pwd.clear();
|
| 129 | pwd.sendKeys("fusion");
|
| 130 | //driver.findElement(By.partialLinkText("Click here to login")).click();
|
| 131 | //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
| 132 |
|
| 133 | loginButton.click();
|
| 134 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
| 135 |
|
| 136 |
|
| 137 | log.info("Clicking Profile link from left pane");
|
| 138 | Thread.sleep(3000);
|
| 139 | System.out.println("properties file details --->"+configProp.getProperty("profilelink"));
|
| 140 | driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click();
|
| 141 | Thread.sleep(3000);
|
| 142 |
|
| 143 | //Verify whether the sub panel is displayed
|
| 144 | //To verify the following :Search import from webphone and Self
|
| 145 | driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed();
|
| 146 | log.info("Expand and collapse passed for Profile link");
|
| 147 |
|
| 148 | //For Admin
|
| 149 | //Verify expand and collapse working for ADMIN
|
| 150 | log.info("Clicking Admin link from left pane");
|
| 151 | driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[6]/a/span")).click();
|
| 152 | //To verify the following: Roles, Roles Functions, Usages
|
| 153 | driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed();
|
| 154 |
|
| 155 |
|
| 156 | log.info("Expand and collapse passed for ADMIN link");
|
| 157 |
|
| 158 | log.info("VID-11 TC-3 PASSED");
|
| 159 |
|
| 160 | }
|
| 161 |
|
| 162 |
|
| 163 | /**
|
| 164 | * Drop down list.
|
| 165 | *
|
| 166 | * @throws InterruptedException the interrupted exception
|
| 167 | */
|
| 168 | @Test(priority=2)
|
| 169 | public void dropDownList() throws InterruptedException
|
| 170 | {
|
| 171 | //VID-12 TC-3
|
| 172 | log.info("VID-12 TC-3");
|
| 173 | //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
|
| 174 |
|
| 175 | //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"));
|
| 176 | Thread.sleep(5000);
|
| 177 |
|
| 178 | //Infrastructure Subscriber Name
|
| 179 | Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")));
|
| 180 | Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")));
|
| 181 |
|
| 182 | List <WebElement> elementCount = oSelect.getOptions();
|
| 183 | log.info("Subscriber Name Drop Down");
|
| 184 | System.out.println(elementCount.size());
|
| 185 | oSelect.selectByIndex(1);
|
| 186 | log.info("Subscriber name selected");
|
| 187 | //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText();
|
| 188 |
|
| 189 |
|
| 190 | List <WebElement> count = iSelect.getOptions();
|
| 191 | log.info("Subscriber type drop down");
|
| 192 | System.out.println(count.size());
|
| 193 | oSelect.selectByIndex(1);
|
| 194 | log.info("Subscriber type selected");
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 | //Submit button is clicked
|
| 199 | driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click();
|
| 200 |
|
| 201 |
|
| 202 | //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
|
| 203 | driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
|
| 204 | log.info("VID-12 TC-3 PASSED");
|
| 205 | }
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 | /**
|
| 211 | * Logout left pane.
|
| 212 | */
|
| 213 | @Test(priority=3)
|
| 214 | public void logoutLeftPane()
|
| 215 | {
|
| 216 | //To Verify if the logout link redirects to Login page when clicked.
|
| 217 |
|
| 218 |
|
| 219 | /*log.info("----------------VID-11 TC-4----------------");
|
| 220 | login.clear();
|
| 221 | login.sendKeys("testuser");
|
| 222 | pwd.clear();
|
| 223 | pwd.sendKeys("abc123");
|
| 224 | //driver.findElement(By.partialLinkText("Click here to login")).click();
|
| 225 | //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
|
| 226 |
|
| 227 | loginButton.click();
|
| 228 | driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/
|
| 229 | log.info("----------------VID-11 TC-4----------------");
|
| 230 | driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[7]/a")).click();
|
| 231 | //Validate that the user has logged out of VID. Displays "Portal"
|
| 232 | Assert.assertTrue(driver.getPageSource().contains("Portal"));
|
| 233 |
|
| 234 | log.info("VID 11 TC-4 PASSED");
|
| 235 |
|
| 236 | driver.close();
|
| 237 |
|
| 238 | }
|
| 239 |
|
| 240 | }
|