2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.ecomp.vid.selenium;
23 import java.io.FileInputStream;
24 import java.io.IOException;
25 import java.io.InputStream;
26 import java.util.List;
27 import java.util.Properties;
28 import java.util.concurrent.TimeUnit;
30 import org.apache.log4j.Logger;
31 import org.openqa.selenium.By;
32 import org.openqa.selenium.WebDriver;
33 import org.openqa.selenium.WebElement;
34 import org.openqa.selenium.firefox.FirefoxDriver;
35 import org.openqa.selenium.support.ui.Select;
36 import org.testng.Assert;
37 import org.testng.annotations.BeforeTest;
38 import org.testng.annotations.Test;
41 * The Class LogOutLeftPane.
44 public class LogOutLeftPane {
46 /** The login button. */
47 WebElement loginButton;
58 /** The errormessage. */
59 WebElement errormessage;
62 WebDriver driver=new FirefoxDriver();
65 /** The config prop. */
66 private final Properties configProp = new Properties();
70 * Instantiates a new log out left pane.
72 private LogOutLeftPane() {
73 // TODO Auto-generated constructor stub
76 // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
77 //FileInputStream input1 = new FileInputStream("objectmap.properties");
79 InputStream input =new FileInputStream("objectconfig.properties");
80 System.out.println("Read all properties from file");
81 configProp.load(input);
82 System.out.println("Read all properties from file completed");
84 catch(IOException e) {
96 // TODO Auto-generated method stub
98 public void doBeforeTest()
100 //WebDriver driver=new FirefoxDriver();
102 log = Logger.getLogger(LogOutLeftPane.class.getName());
107 driver.get("http://vid.openecomp.org:9080/vid/login_external.htm");
108 driver.manage().window().maximize();
111 login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
112 pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
113 loginButton = driver.findElement(By.id("loginBtn"));
118 * Expand collapse panel.
120 * @throws InterruptedException the interrupted exception
123 public void expandCollapsePanel() throws InterruptedException
129 login.sendKeys("su");
131 pwd.sendKeys("fusion");
132 //driver.findElement(By.partialLinkText("Click here to login")).click();
133 //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
136 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
139 log.info("Clicking Profile link from left pane");
141 System.out.println("properties file details --->"+configProp.getProperty("profilelink"));
142 driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click();
145 //Verify whether the sub panel is displayed
146 //To verify the following :Search import from webphone and Self
147 driver.findElement(By.xpath(".//*[@id='panel4']")).isDisplayed();
148 log.info("Expand and collapse passed for Profile link");
151 //Verify expand and collapse working for ADMIN
152 log.info("Clicking Admin link from left pane");
153 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();
154 //To verify the following: Roles, Roles Functions, Usages
155 driver.findElement(By.xpath(".//*[@id='panel5']")).isDisplayed();
158 log.info("Expand and collapse passed for ADMIN link");
160 log.info("VID-11 TC-3 PASSED");
168 * @throws InterruptedException the interrupted exception
171 public void dropDownList() throws InterruptedException
174 log.info("VID-12 TC-3");
175 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
177 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"));
180 //Infrastructure Subscriber Name
181 Select oSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")));
182 Select iSelect = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")));
184 List <WebElement> elementCount = oSelect.getOptions();
185 log.info("Subscriber Name Drop Down");
186 System.out.println(elementCount.size());
187 oSelect.selectByIndex(1);
188 log.info("Subscriber name selected");
189 //String selectedOption = new Select(driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"))).getFirstSelectedOption().getText();
192 List <WebElement> count = iSelect.getOptions();
193 log.info("Subscriber type drop down");
194 System.out.println(count.size());
195 oSelect.selectByIndex(1);
196 log.info("Subscriber type selected");
200 //Submit button is clicked
201 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click();
204 //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
205 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
206 log.info("VID-12 TC-3 PASSED");
216 public void logoutLeftPane()
218 //To Verify if the logout link redirects to Login page when clicked.
221 /*log.info("----------------VID-11 TC-4----------------");
223 login.sendKeys("ss749s");
225 pwd.sendKeys("abc123");
226 //driver.findElement(By.partialLinkText("Click here to login")).click();
227 //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
230 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);*/
231 log.info("----------------VID-11 TC-4----------------");
232 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();
233 //Validate that the user has logged out of VID. Displays "Portal"
234 Assert.assertTrue(driver.getPageSource().contains("Portal"));
236 log.info("VID 11 TC-4 PASSED");