org.onap migration
[vid.git] / vid-automation / src / main / java / vid / automation / test / infra / Input.java
1 package vid.automation.test.infra;
2
3 import org.apache.commons.io.FilenameUtils;
4 import org.apache.commons.lang3.SystemUtils;
5 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
6 import org.openqa.selenium.WebElement;
7
8 /**
9  * Created by itzikliderman on 11/09/2017.
10  */
11 public class Input {
12     public static void text(String text, String inputTestsId) {
13         WebElement inputElement = GeneralUIUtils.getWebElementByTestID(inputTestsId, 30);
14         inputElement.sendKeys(text);
15     }
16
17     public static String getValueByTestId(String testId) {
18         WebElement input = GeneralUIUtils.getInputElement(testId);
19         return input.getAttribute("value");
20     }
21
22     /*
23         Get relative path to resource and id of file input element,
24         and send the resource full path to the input element
25      */
26     public static void file(String pathInResources, String inputId) {
27
28         String path = Input.class.getResource("../../../../"+pathInResources).getPath().toString();
29         if (SystemUtils.IS_OS_WINDOWS) {
30             path = FilenameUtils.separatorsToSystem(path);
31             if (path.charAt(0)=='\\') {
32                 path = path.substring(1);
33             }
34         }
35         WebElement inputElement = Get.byId(inputId);
36         inputElement.sendKeys(path);
37     }
38 }