Fix getManualTasks double-addition of baseUrl
[vid.git] / vid-automation / src / main / java / vid / automation / test / infra / SelectOption.java
1 package vid.automation.test.infra;
2
3 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
4 import org.openqa.selenium.WebElement;
5 import org.openqa.selenium.support.ui.Select;
6 import vid.automation.test.Constants;
7
8 import java.util.List;
9
10 /**
11  * Created by itzikliderman on 18/07/2017.
12  */
13 public class SelectOption {
14     public static Select byValue(String value, String dataTestsId) {
15         Select select = new Select(GeneralUIUtils.getWebElementByTestID(dataTestsId));
16         if(value != null) {
17             select.selectByValue(value);
18         }
19
20         return select;
21     }
22
23     public static Select byIdAndVisibleText(String id, String text) {
24         Select selectlist = new Select(Get.byId(id));
25         if(text != null) {
26             selectlist.selectByVisibleText(text);
27         }
28
29         return selectlist;
30     }
31
32     public static void byClassAndVisibleText(String className, String text) {
33         final List<WebElement> webElements = Get.byClass(className);
34         webElements.forEach(webElement -> {
35             final String id = webElement.getAttribute("id");
36             byIdAndVisibleText(id, text);
37         });
38     }
39     public static List<WebElement> getList(String selectDataTestId) {
40         Select selectList = GeneralUIUtils.getSelectList(null, selectDataTestId);
41         return selectList.getOptions();
42     }
43     public static String getSelectedOption(String selectDataTestId) {
44         Select selectList = GeneralUIUtils.getSelectList(null, selectDataTestId);
45         return selectList.getFirstSelectedOption().getText();
46     }
47     public static void byTestIdAndVisibleText(String displayName, String selectDataTestId) {
48         GeneralUIUtils.getSelectList(displayName, selectDataTestId);
49     }
50
51     public static void selectFirstTwoOptionsFromMultiselectById(String multiSelectId) throws InterruptedException {
52         Click.byId(multiSelectId);
53         Thread.sleep(1000);
54         Click.byClass(Constants.MULTI_SELECT_UNSELECTED_CLASS);
55         Click.byClass(Constants.MULTI_SELECT_UNSELECTED_CLASS);
56
57     }
58
59     public static void selectOptionsFromMultiselectById(String multiSelectId, List<String> options) {
60         Click.byId(multiSelectId);
61         try {
62             Thread.sleep(1000);
63         } catch (InterruptedException e) {
64             throw new RuntimeException(e);
65         }
66         for(String option:options) {
67             Click.byClassAndVisibleText(Constants.MULTI_SELECT_UNSELECTED_CLASS, option);
68         }
69     }
70 }