Merge automation from ECOMP's repository
[vid.git] / vid-automation / src / main / java / vid / automation / test / infra / SelectOption.java
index dc792cf..cd766c5 100644 (file)
@@ -1,11 +1,14 @@
 package vid.automation.test.infra;
 
-import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
+import com.google.common.collect.ImmutableList;
+import org.apache.commons.lang3.ObjectUtils;
+import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
 import org.openqa.selenium.WebElement;
 import org.openqa.selenium.support.ui.Select;
 import vid.automation.test.Constants;
 
 import java.util.List;
+import java.util.concurrent.TimeUnit;
 
 /**
  * Created by itzikliderman on 18/07/2017.
@@ -56,6 +59,13 @@ public class SelectOption {
 
     }
 
+    public static void waitForOptionInSelect(String option, String selectTestId) {
+        Wait.waitFor(foo ->
+                        ObjectUtils.defaultIfNull(SelectOption.getList(selectTestId), ImmutableList.<WebElement>of())
+                                .stream().map(o -> o.getText()).filter(o -> option.equals(o)).findAny().isPresent(),
+                "", 10, 200, TimeUnit.MILLISECONDS);
+    }
+
     public static void selectOptionsFromMultiselectById(String multiSelectId, List<String> options) {
         Click.byId(multiSelectId);
         try {