From 1cfb08779ea0e00be69e072a940b3063e049fe6b Mon Sep 17 00:00:00 2001 From: Ofir Sonsino Date: Wed, 31 Jan 2018 17:19:00 +0200 Subject: org.onap migration Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d Issue-ID: VID-86 Signed-off-by: Ofir Sonsino --- .../main/java/vid/automation/test/infra/Get.java | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 vid-automation/src/main/java/vid/automation/test/infra/Get.java (limited to 'vid-automation/src/main/java/vid/automation/test/infra/Get.java') 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 00000000..f9ce529f --- /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 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 byClass(String className) { + return GeneralUIUtils.getWebElementsListByContainsClassName(className); + } + + public static WebElement byCssSelector(String css) { + return GeneralUIUtils.getDriver().findElement(By.cssSelector(css)); + } + + public static List tableHeaderValuesByTestId(String tableId) { + return tableValuesById(tableId, "thead", "th").get(0); + } + + public static List> tableBodyValuesByTestId(String tableId) { + return tableValuesById(tableId, "tbody", "td"); + } + + private static List 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> tableValuesById(String tableId, String section, String column) { + List rows = rowsByTableId(tableId, section, column); + if(rows != null) { + List> tableContent = new ArrayList>(); + for(WebElement row:rows) { + List columns = row.findElements(By.xpath(column)); + tableContent.add(GeneralUIUtils.getWebElementListText(columns)); + } + return tableContent; + } + else { + return null; + } + } +} -- cgit 1.2.3-korg