Merge automation from ECOMP's repository
[vid.git] / vid-automation / src / main / java / org / onap / sdc / ci / tests / utilities / LoginUtils.java
1 package org.onap.sdc.ci.tests.utilities;
2
3 import org.onap.sdc.ci.tests.datatypes.UserCredentials;
4 import org.onap.sdc.ci.tests.datatypes.UserRoleEnum;
5 import org.openqa.selenium.By;
6 import org.openqa.selenium.WebDriver;
7 import org.openqa.selenium.WebElement;
8 import org.openqa.selenium.support.ui.ExpectedConditions;
9 import org.openqa.selenium.support.ui.WebDriverWait;
10
11 public class LoginUtils {
12
13         private static final String WEB_SEAL_PASSWORD = "123123a";
14
15         public static void loginToLocalWebsealSimulator(UserRoleEnum role) {
16                 WebDriver driver = GeneralUIUtils.getDriver();
17                 WebDriverWait wait = new WebDriverWait(driver, 30);
18
19                 wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']"))));
20
21                 WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId"));
22                 userIdTextbox.sendKeys(role.getUserId());
23                 WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
24                 passwordTextbox.sendKeys(WEB_SEAL_PASSWORD);
25
26                 wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click();
27         }
28         
29         public static void loginToLocalWebsealSimulator(UserCredentials user) {
30                 WebDriver driver = GeneralUIUtils.getDriver();
31                 WebDriverWait wait = new WebDriverWait(driver, 30);
32
33                 wait.until(ExpectedConditions.visibilityOf(driver.findElement(By.xpath("//*[@method='" + "post" + "']"))));
34
35                 WebElement userIdTextbox = GeneralUIUtils.getWebElementBy(By.name("userId"));
36                 userIdTextbox.sendKeys(user.getUserId());
37                 WebElement passwordTextbox = GeneralUIUtils.getWebElementBy(By.name("password"));
38                 passwordTextbox.sendKeys(user.getPassword());
39
40                 wait.until(ExpectedConditions.elementToBeClickable(driver.findElement(By.xpath("//*[@value='" + "Login" + "']")))).click();
41         }
42 }