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