1 package vid.automation.test.infra;
3 import org.junit.Assert;
4 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
5 import org.openqa.selenium.Alert;
6 import org.openqa.selenium.By;
7 import org.openqa.selenium.Keys;
8 import org.openqa.selenium.WebElement;
9 import org.openqa.selenium.support.ui.ExpectedConditions;
10 import org.openqa.selenium.support.ui.Select;
11 import org.openqa.selenium.support.ui.WebDriverWait;
13 import java.util.List;
16 public static void byText(String text) {
17 WebElement element = GeneralUIUtils.findByText(text);
18 Assert.assertTrue(element != null);
23 public static void byId(String id) {
24 WebElement element = Get.byId(id);
25 Assert.assertTrue(element != null);
30 public static void byTestId(String testId) {
31 WebElement element = Get.byTestId(testId);
32 Assert.assertTrue(element != null);
36 public static void byClass(String className) {
37 List<WebElement> elements = Get.byClass(className);
38 Assert.assertTrue(elements != null && elements.size() > 0);
40 elements.get(0).click();
43 public static void byXpath(String xpath) {
44 WebElement element = Get.byXpath(xpath);
45 Assert.assertNotNull(element);
50 public static void onFirstSelectOptionById(String id) {
51 Select selectlist = new Select(Get.byId(id));
52 if(selectlist.getOptions().size() > 1) {
53 selectlist.selectByIndex(1);
57 public static void onFirstSelectOptionByTestId(String dataTestId) {
58 Select selectList = new Select(Get.byTestId(dataTestId));
59 if(selectList.getOptions().size() > 1) {
60 selectList.selectByIndex(1);
64 public static void onFirstSelectOptionByClass(String className) {
65 final List<WebElement> webElements = Get.byClass(className);
66 webElements.forEach(webElement -> {
67 Select selectlist = new Select(webElement);
68 if (selectlist.getOptions().size() > 1) {
69 selectlist.selectByIndex(1);
74 public static void byClassAndVisibleText(String className, String text ) {
75 WebElement element = Get.byClassAndText(className, text);
81 public static void acceptAlert() {
82 Alert alert = GeneralUIUtils.getDriver().switchTo().alert();
83 Assert.assertTrue(alert != null);