2 * ============LICENSE_START=======================================================
\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
11 * http://www.apache.org/licenses/LICENSE-2.0
\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
21 package org.openecomp.ecomp.vid.selenium;
\r
23 import org.testng.annotations.AfterClass;
\r
24 import org.testng.annotations.AfterMethod;
\r
25 import org.testng.annotations.AfterSuite;
\r
26 import org.testng.annotations.BeforeClass;
\r
27 import org.testng.annotations.BeforeMethod;
\r
28 import org.testng.annotations.BeforeSuite;
\r
29 import org.testng.annotations.BeforeTest;
\r
30 import org.testng.annotations.Test;
\r
33 import org.openqa.selenium.By;
\r
34 import org.openqa.selenium.WebDriver;
\r
35 import org.openqa.selenium.WebElement;
\r
36 import org.openqa.selenium.firefox.FirefoxDriver;
\r
37 import org.openqa.selenium.ie.InternetExplorerDriver;
\r
38 import org.openqa.selenium.support.ui.Select;
\r
40 import java.io.FileInputStream;
\r
41 import java.io.IOException;
\r
42 import java.io.InputStream;
\r
43 import java.util.List;
\r
44 import java.util.Properties;
\r
45 import java.util.concurrent.TimeUnit;
\r
46 import org.apache.log4j.Logger;
\r
47 import org.testng.Assert;
\r
48 import org.testng.asserts.*;
\r
51 * The Class FirstClass.
\r
53 public class FirstClass {
\r
55 /** The login button. */
\r
56 WebElement loginButton;
\r
70 /** The errormessage. */
\r
71 WebElement errormessage;
\r
75 WebDriver driver=new FirefoxDriver();
\r
79 /** The config prop. */
\r
80 private final Properties configProp = new Properties();
\r
84 * Instantiates a new first class.
\r
86 private FirstClass() {
\r
87 // TODO Auto-generated constructor stub
\r
90 // InputStream input =this.getClass().getClassLoader().getResourceAsStream("objectmap.properties");
\r
91 //FileInputStream input1 = new FileInputStream("objectmap.properties");
\r
93 InputStream input =new FileInputStream("objectconfig.properties");
\r
94 System.out.println("Read all properties from file");
\r
95 configProp.load(input);
\r
96 System.out.println("Read all properties from file completed");
\r
98 catch(IOException e) {
\r
100 e.printStackTrace();
\r
109 public void setUp() {
\r
110 System.out.println("*******************");
\r
111 System.out.println("launching IE browser");
\r
112 System.setProperty("webdriver.ie.driver", driverPath+"IEDriverServer.exe");
\r
113 driver = new InternetExplorerDriver();
\r
114 driver.findElement(By.className());
\r
115 driver.manage().window().maximize();
\r
118 login = driver.findElement(By.xpath("//input[@class='fn-ebz-text ng-pristine ng-valid']"));
\r
119 pwd = driver.findElement(By.xpath("//input[@class='span3 ng-pristine ng-valid']"));
\r
120 loginButton = driver.findElement(By.id("loginBtn"));
\r
128 // TODO Auto-generated method stub
\r
130 public void setUp()
\r
134 //WebDriver driver=new FirefoxDriver();
\r
136 log = Logger.getLogger(FirstClass.class.getName());
\r
141 driver.get(configProp.getProperty("baseURL"));
\r
142 driver.manage().window().maximize();
\r
145 login = driver.findElement(By.xpath(configProp.getProperty("login")));
\r
147 pwd = driver.findElement(By.xpath(configProp.getProperty("pwd")));
\r
148 loginButton = driver.findElement(By.id(configProp.getProperty("loginButton")));
\r
153 * Empty username password.
\r
156 public void emptyUsernamePassword()
\r
160 //User Name and Password field is empty
\r
161 log.info("-----VID-11 TC-8----Username and password empty");
\r
162 loginButton.click();
\r
163 errormessage=driver.findElement(By.xpath("//*[@id='errorInfo']/span"));
\r
164 String errmsg= errormessage.getText();
\r
165 //System.out.println("Error message is"+errmsg);
\r
166 //String expected = "Invaild username or password, Please try again";
\r
168 //Assert.assertEquals(errmsg,expected);
\r
170 Boolean str = driver.getPageSource().contains("Invalid username or password, Please try again");
\r
171 System.out.println(driver.getPageSource().contains("Invalid username or password, Please try again"));
\r
175 log.info("Error message validated");
\r
176 log.info("VID-11 TC-8 PASSED");
\r
179 log.error("Failed validation");
\r
186 * Invalid user name.
\r
189 public void invalidUserName()
\r
192 log.info("-----VID-11 TC-6----Invalid Username and Valid Password");
\r
195 login.sendKeys("xxx");
\r
196 pwd.sendKeys("abc123");
\r
197 loginButton.click();
\r
199 Thread.sleep(5000);
\r
200 } catch (InterruptedException e) {
\r
201 // TODO Auto-generated catch block
\r
202 e.printStackTrace();
\r
205 String errmsg= errormessage.getText();
\r
206 String expected = "Invalid username or password, Please try again";
\r
207 Assert.assertEquals(errmsg,expected);
\r
208 //Boolean str1 = driver.getPageSource().contains("Invalid username or password, Please try again");
\r
209 //System.out.print(str1);
\r
211 log.info("VID-11 TC-6 PASSED");
\r
217 * Invalid password.
\r
220 public void invalidPassword()
\r
222 log.info("-----VID-11 TC-7----Valid Username and Invalid Password");
\r
223 // Valid user name and Invalid password.
\r
226 login.sendKeys("testuser");
\r
227 pwd.sendKeys("xxx");
\r
228 loginButton.click();
\r
229 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
\r
232 String errmsg= errormessage.getText();
\r
233 String expected = "Invalid username or password, Please try again";
\r
234 Assert.assertEquals(errmsg,expected);
\r
236 //Boolean str2 = driver.getPageSource().contains("Invaild username or password, Please try again");
\r
237 //System.out.print(str2);
\r
239 log.info("VID-11 TC-7 PASSED");
\r
244 * Login successful.
\r
247 public void loginSuccessful()
\r
249 log.info("-----VID-11 TC-1----Valid Username and Valid Password");
\r
250 //Login with valid user name and password.
\r
252 login.sendKeys("su");
\r
254 pwd.sendKeys("fusion");
\r
257 loginButton.click();
\r
258 driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
\r
261 Thread.sleep(6000);
\r
262 } catch (InterruptedException e) {
\r
263 // TODO Auto-generated catch block
\r
264 e.printStackTrace();
\r
266 Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
\r
267 log.info("VID-11 TC-1 PASSED");
\r
273 * Verify home page elements left pane.
\r
276 public void verifyHomePageElementsLeftPane()
\r
281 log.info("VID-10 TC 1 ");
\r
283 log.info("VID 11 TC-2");
\r
284 driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[1]/a/span")).isDisplayed();
\r
285 //Create New Service Instance
\r
286 driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[2]/a/span")).isDisplayed();
\r
288 //Browse Service Type
\r
289 driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[3]/a/span")).isDisplayed();
\r
291 driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[4]/a/span")).isDisplayed();
\r
294 driver.findElement(By.xpath("html/body/div[1]/div[1]/div/div/div[2]/div/div/div[1]/div/div/accordion/div/div[5]/a/span")).isDisplayed();
\r
296 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")).isDisplayed();
\r
298 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/span")).isDisplayed();
\r
300 //Infrastructure Subscriber Name
\r
301 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[1]/div/label")).isDisplayed();
\r
302 //Infrastructure Subscriber Name Select Drop down
\r
303 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select")).isDisplayed();
\r
304 //Infrastructure Service Type
\r
305 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[1]/div/label")).isDisplayed();
\r
306 //Infrastructure Service Type Select Drop down
\r
307 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select")).isDisplayed();
\r
309 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[3]/td/div/button")).isDisplayed();
\r
311 //Login Snippet Icon
\r
312 driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).isDisplayed();
\r
315 //String bodyText = driver.findElement(By.tagName("body")).getText();
\r
316 //Assert.assertTrue("Text not found!", bodyText.contains("Search Existing Service Instances"));
\r
317 //Assert.IsTrue(driver.getPageSource.Contains("Search Existing Service Instances"));
\r
319 log.info("VID-12 TC-1");
\r
320 Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
\r
321 Assert.assertTrue(driver.getPageSource().contains("Please search by the Subscriber name or Service Type from below:"));
\r
322 log.info("VID-12 TC-1 PASSED");
\r
323 log.info("VID-10 TC 1 PASSED");
\r
324 log.info("VID-11 TC-2 PASSED");
\r
329 * Disabled submit button.
\r
332 public void disabledSubmitButton()
\r
334 log.info("VID-12 TC-13");
\r
335 //Assert submit button disabled.
\r
336 Assert.assertFalse(driver.findElement(By.xpath(configProp.getProperty("submitButton"))).isEnabled());
\r
337 log.info("VID-12 TC-13 PASSED");
\r
342 * Default list box value.
\r
345 public void defaultListBoxValue()
\r
347 log.info("VID-12 TC-2");
\r
350 //WebElement subscribername =driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select"));
\r
352 Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
\r
353 Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
\r
356 WebElement ielement=iSelect.getFirstSelectedOption();
\r
357 WebElement oelement=oSelect.getFirstSelectedOption();
\r
358 String defaultsubscribername=oelement.getText();
\r
359 String defaultservicetype=ielement.getText();
\r
361 Assert.assertEquals(defaultsubscribername,"Select Subscriber Name");
\r
362 Assert.assertEquals(defaultservicetype,"Select Service Type");
\r
367 //Verify Select Subscriber Name isDisplayed.
\r
368 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[1]/td[2]/div/select/option[1]")).isSelected();
\r
370 //Verify Select Service Type isDisplayed.
\r
371 //driver.findElement(By.xpath(".//*[@id='mContent']/div/div/table/tbody/tr[2]/td[2]/div/select/option[1]")).isSelected();
\r
374 log.info("VID-12 TC-2 PASSED");
\r
381 * Select subscriber name drop down.
\r
383 * @throws InterruptedException the interrupted exception
\r
386 public void selectSubscriberNameDropDown() throws InterruptedException
\r
388 log.info("------------------VID-10 TC-2,VID-12 TC-11, VID-12 TC-9, VID 12 TC-10,VID-12 TC-6, VID 12 TC-5--------------------");
\r
391 driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")));
\r
393 driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown")));
\r
394 Thread.sleep(5000);
\r
396 //Infrastructure Subscriber Name
\r
397 Select oSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown"))));
\r
399 List <WebElement> elementCount = oSelect.getOptions();
\r
400 log.info("Select Element Count of Service Name");
\r
401 System.out.println(elementCount.size());
\r
404 //Verifying getInfrastructureSubscribersList
\r
405 log.info("VID-29 TC-1");
\r
406 Assert.assertTrue(elementCount.size()>0);
\r
407 log.info("VID-29 TC-1 PASSED");
\r
409 oSelect.selectByIndex(2);
\r
410 String selectedOption = new Select(driver.findElement(By.xpath(configProp.getProperty("subscriberNameDropDown")))).getFirstSelectedOption().getText();
\r
412 System.out.println("Service Name selected is " +selectedOption);
\r
413 log.info("VID-10 TC-2 PASSED");
\r
415 //Submit button is clicked
\r
416 driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
\r
419 //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
\r
420 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
\r
421 //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
\r
424 //Verify whether the page header is displayed "Global Customer ID"
\r
425 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
\r
426 Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
\r
427 Assert.assertTrue(driver.getPageSource().contains("Subscriber Name"));
\r
428 Assert.assertTrue(driver.getPageSource().contains("Service Type"));
\r
429 Assert.assertTrue(driver.getPageSource().contains("Service Instance ID"));
\r
431 log.info("VID-12 TC-5 PASSED");
\r
432 log.info("VID-12 TC-11 PASSED");
\r
434 WebElement serviceinstancetable =driver.findElement(By.xpath("//table[@class='tablesorter tablesorter-default ng-isolate-scope']"));
\r
436 List<WebElement> rows_table = serviceinstancetable.findElements(By.tagName("tr"));
\r
437 //To calculate no of rows In table.
\r
438 int rows_count = rows_table.size();
\r
440 //Loop will execute till the last row of table.
\r
441 for (int row=0; row<rows_count; row++){
\r
442 //To locate columns(cells) of that specific row.
\r
443 List<WebElement> Columns_row = rows_table.get(row).findElements(By.tagName("td"));
\r
444 //To calculate no of columns(cells) In that specific row.
\r
445 int columns_count = Columns_row.size();
\r
446 //System.out.println("Number of cells In Row "+row+" are "+columns_count);
\r
448 //Loop will execute till the last cell of that specific row.
\r
449 for (int column=0; column<columns_count; column++){
\r
450 //To retrieve text from that specific cell.
\r
451 String celtext = Columns_row.get(column).getText();
\r
452 //System.out.println("Cell Value Of row number "+row+" and column number "+column+" Is "+celtext);
\r
456 //log.info("Testing Get column and row value");
\r
457 List <WebElement> exx= rows_table.get(1).findElements(By.tagName("td"));
\r
458 eg=Columns_row.get(2).getText();
\r
459 // System.out.println("Cell value of row 1 and column 2 is" +eg);
\r
466 //Verify View/Edit isDisplayed and Click
\r
468 driver.findElement(By.xpath("//a[@alt='View/Edit']")).isDisplayed();
\r
470 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/tbody/tr[1]/td[1]/div/a")).click();
\r
472 log.info("User clicked View/Edit");
\r
474 //Verify the Subscriber Name displayed.
\r
475 String header= driver.findElement(By.xpath("//h1[@class='heading1 ng-binding']")).getText();
\r
476 //System.out.println(header);
\r
479 if(header.contains(eg))
\r
481 System.out.println("Header contains the subscriber name");
\r
483 System.out.println("Header does not contain the subscriber name");
\r
487 Assert.assertTrue(driver.getPageSource().contains("PerfTest Subscriber00020021"));
\r
488 log.info("VID-12 TC-6 PASSED");
\r
492 driver.navigate().back();
\r
493 //Cancel button isDisplayed
\r
494 driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).isDisplayed();
\r
495 log.info("VID-12 TC-9 PASSED");
\r
497 //Cancel button is clicked
\r
498 driver.findElement(By.xpath("//button[@class='button button--small button--primary']")).click();
\r
499 log.info("Cancel button is clicked");
\r
501 //Verifying VID Home page is displayed
\r
502 Assert.assertTrue(driver.getPageSource().contains("Search Existing Service Instances"));
\r
503 log.info("VID-12 TC-10 PASSED");
\r
509 * Refresh subscriber name.
\r
512 public void refreshSubscriberName()
\r
514 log.info("VID-10 TC-4");
\r
517 driver.findElement(By.xpath(configProp.getProperty("refreshButtonSubscriberName"))).isDisplayed();
\r
519 log.info("VID-10 TC-4 PASSED");
\r
526 * Select subscriber type drop down.
\r
528 * @throws InterruptedException the interrupted exception
\r
531 public void selectSubscriberTypeDropDown() throws InterruptedException
\r
533 Thread.sleep(5000);
\r
534 log.info("------------------VID-10 TC-3, VID-12 TC-12,--------------------");
\r
535 //Infrastructure Subscriber Type
\r
536 Select iSelect = new Select(driver.findElement(By.xpath(configProp.getProperty("serviceTypeDropDown"))));
\r
538 List <WebElement> ielementCount = iSelect.getOptions();
\r
539 log.info("Select Element Count of Service type");
\r
540 System.out.println(ielementCount.size());
\r
541 iSelect.selectByIndex(1);
\r
543 log.info("VID-10 TC-3 PASSED");
\r
546 //Submit button is clicked
\r
547 driver.findElement(By.xpath(configProp.getProperty("submitButton"))).click();
\r
549 //Verify whether the page header is displayed "Selected Subscriber's Service Instance Details:"
\r
550 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/h1")).isDisplayed();
\r
551 //Assert.assertTrue(driver.getPageSource().contains("Selected Subscriber's Service Instance Details:"))
\r
552 log.info("Page Header: Selected Subscriber's Service Instance Details");
\r
555 //Verify whether the page header is displayed "Global Customer ID"
\r
556 driver.findElement(By.xpath(".//*[@id='mContent']/div/div/div/div/table/thead/tr/th[2]/div")).isDisplayed();
\r
558 //Assert.assertTrue(driver.getPageSource().contains("Global Customer ID"));
\r
559 log.info("Table is displayed");
\r
561 log.info("VID-12 TC-12 PASSED");
\r
568 * Logout under profile.
\r
571 public void logoutUnderProfile()
\r
574 log.info("-----------VID-11 TC-5---------------------");
\r
575 //driver.findElement(By.partialLinkText("Click here to login")).click();
\r
576 //driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
\r
579 driver.findElement(By.xpath(".//*[@class='icon-user-small login-snippet-icon']")).click();
\r
580 driver.findElement(By.xpath(".//*[@id='reg-logout-div']/a")).click();
\r
581 //Validate that the user has logged out of VID. Displays "Portal"
\r
582 Assert.assertTrue(driver.getPageSource().contains("Portal"));
\r
584 log.info("VID-11 TC-5 PASSED");
\r
594 public void tearDown()
\r