aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/vid/automation/test/infra/Get.java
diff options
context:
space:
mode:
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/infra/Get.java')
-rw-r--r--vid-automation/src/main/java/vid/automation/test/infra/Get.java95
1 files changed, 95 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/infra/Get.java b/vid-automation/src/main/java/vid/automation/test/infra/Get.java
new file mode 100644
index 000000000..f9ce529f8
--- /dev/null
+++ b/vid-automation/src/main/java/vid/automation/test/infra/Get.java
@@ -0,0 +1,95 @@
+package vid.automation.test.infra;
+
+import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Get {
+ public static WebElement byId(String id) {
+ try {
+ return GeneralUIUtils.getDriver().findElement(By.id(id));
+ } catch (Exception var2) {
+ return null;
+ }
+ }
+
+ public static WebElement byTestId(String dataTestId) {
+ try {
+ return GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"));
+ } catch (Exception var2) {
+ return null;
+ }
+ }
+
+
+
+ public static WebElement byClassAndText(String className, String text) {
+ WebElement result = null;
+ List<WebElement> elements = GeneralUIUtils.getWebElementsListByContainsClassName(className);
+
+ for(WebElement element : elements) {
+ if (element.getText().contains(text)) {
+ result = element;
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ public static WebElement byCssSelectorAndText(String css, String text) {
+ WebElement element = GeneralUIUtils.getDriver().findElement(By.cssSelector(css));
+
+ if (element != null && element.getText().contains(text)) {
+ return element;
+ }
+
+ return null;
+ }
+
+ public static String selectedOptionText(String dataTestId) {
+ return GeneralUIUtils.getSelectedElementFromDropDown(dataTestId).getText();
+ }
+
+ public static List<WebElement> byClass(String className) {
+ return GeneralUIUtils.getWebElementsListByContainsClassName(className);
+ }
+
+ public static WebElement byCssSelector(String css) {
+ return GeneralUIUtils.getDriver().findElement(By.cssSelector(css));
+ }
+
+ public static List<String> tableHeaderValuesByTestId(String tableId) {
+ return tableValuesById(tableId, "thead", "th").get(0);
+ }
+
+ public static List<List<String>> tableBodyValuesByTestId(String tableId) {
+ return tableValuesById(tableId, "tbody", "td");
+ }
+
+ private static List<WebElement> rowsByTableId(String tableId,String section, String column) {
+ try {
+ return GeneralUIUtils.getElemenetsFromTable(By.xpath("//table[@data-tests-id=\"" + tableId + "\"]/" + section + "/tr"));
+ } catch (Exception var2) {
+ return null;
+ }
+ }
+
+ private static List<List<String>> tableValuesById(String tableId, String section, String column) {
+ List<WebElement> rows = rowsByTableId(tableId, section, column);
+ if(rows != null) {
+ List<List<String>> tableContent = new ArrayList<List<String>>();
+ for(WebElement row:rows) {
+ List<WebElement> columns = row.findElements(By.xpath(column));
+ tableContent.add(GeneralUIUtils.getWebElementListText(columns));
+ }
+ return tableContent;
+ }
+ else {
+ return null;
+ }
+ }
+}