actually adding the files to the initial commit
[vid.git] / vid / src / test / java / org / openecomp / ecomp / vid / selenium / LogOutLeftPane.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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
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 package org.openecomp.ecomp.vid.selenium;
22
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;
29
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;
39
40 /**
41  * The Class LogOutLeftPane.
42  */
43 @Test(enabled=true)
44 public class LogOutLeftPane {
45
46         /** The login button. */
47         WebElement loginButton;
48         
49         /** The login. */
50         WebElement login;
51         
52         /** The pwd. */
53         WebElement pwd;
54         
55         /** The log. */
56         Logger log;
57         
58         /** The errormessage. */
59         WebElement errormessage;
60         
61         /** The driver. */
62         WebDriver driver=new FirefoxDriver();
63         
64         
65         /** The config prop. */
66         private final Properties configProp = new Properties();
67         
68         
69         /**
70          * Instantiates a new log out left pane.
71          */
72         private  LogOutLeftPane() {
73                 // TODO Auto-generated constructor stub
74                 //
75                 try{
76                 //      InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
77                 //FileInputStream input1 = new FileInputStream("objectmap.properties");
78                         
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");
83                 }
84                 catch(IOException e) {
85                         
86                         e.printStackTrace();
87                 }
88         }
89         
90         
91            
92            
93         /**
94          * Do before test.
95          */
96         // TODO Auto-generated method stub
97         @BeforeTest
98         public void doBeforeTest()
99         {
100                 //WebDriver driver=new FirefoxDriver();
101                 
102                 log = Logger.getLogger(LogOutLeftPane.class.getName());
103         
104         
105         
106         // Get url
107         driver.get("http://vid.openecomp.org:9080/vid/login_external.htm");
108         driver.manage().window().maximize();
109         
110         
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"));
114         }
115         
116         
117         /**
118          * Expand collapse panel.
119          *
120          * @throws InterruptedException the interrupted exception
121          */
122         @Test(priority=1)
123         public void expandCollapsePanel() throws InterruptedException
124         {
125
126                 
127                 
128                 login.clear();
129                 login.sendKeys("su");
130                 pwd.clear();
131                 pwd.sendKeys("fusion");
132                 //driver.findElement(By.partialLinkText("Click here to login")).click();
133                 //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
134                 
135                 loginButton.click();
136                 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
137                 
138                 
139                 log.info("Clicking Profile link from left pane");
140                 Thread.sleep(3000);
141                 System.out.println("properties file details --->"+configProp.getProperty("profilelink"));
142                 driver.findElement(By.xpath(configProp.getProperty("profilelink"))).click();
143                 Thread.sleep(3000);
144                 
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");
149                 
150                 //For Admin
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();
156                 
157         
158                 log.info("Expand and collapse passed for ADMIN link");
159
160                 log.info("VID-11 TC-3 PASSED");
161                 
162         }
163         
164         
165         /**
166          * Drop down list.
167          *
168          * @throws InterruptedException the interrupted exception
169          */
170         @Test(priority=2)
171         public void dropDownList() throws InterruptedException
172         {
173                 //VID-12 TC-3
174                 log.info("VID-12 TC-3");
175                 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
176                 
177                 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select"));
178                 Thread.sleep(5000);
179                 
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")));
183                 
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();
190                 
191                 
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");
197                 
198
199                                 
200                 //Submit button is clicked
201                 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).click();
202                 
203                 
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");
207         }
208         
209         
210         
211         
212         /**
213          * Logout left pane.
214          */
215         @Test(priority=3)
216         public void logoutLeftPane()
217         {
218                 //To Verify if the logout link redirects to Login page when clicked.
219                 
220                 
221                 /*log.info("----------------VID-11 TC-4----------------");
222                 login.clear();
223                 login.sendKeys("ss749s");
224                 pwd.clear();
225                 pwd.sendKeys("abc123");
226                 //driver.findElement(By.partialLinkText("Click here to login")).click();
227                 //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
228                 
229                 loginButton.click();
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"));
235                 
236                 log.info("VID 11 TC-4 PASSED");
237                 
238                 driver.close();
239                 
240         }
241         
242 }