1 package vid.automation.test.infra;
3 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
4 import org.openqa.selenium.By;
5 import org.openqa.selenium.WebElement;
7 import java.util.ArrayList;
11 public static WebElement byId(String id) {
13 return GeneralUIUtils.getDriver().findElement(By.id(id));
14 } catch (Exception var2) {
19 public static WebElement byTestId(String dataTestId) {
21 return GeneralUIUtils.getDriver().findElement(By.xpath("//*[@data-tests-id='" + dataTestId + "']"));
22 } catch (Exception var2) {
29 public static WebElement byClassAndText(String className, String text) {
30 WebElement result = null;
31 List<WebElement> elements = GeneralUIUtils.getWebElementsListByContainsClassName(className);
33 for(WebElement element : elements) {
34 if (element.getText().contains(text)) {
43 public static WebElement byCssSelectorAndText(String css, String text) {
44 WebElement element = GeneralUIUtils.getDriver().findElement(By.cssSelector(css));
46 if (element != null && element.getText().contains(text)) {
53 public static String selectedOptionText(String dataTestId) {
54 return GeneralUIUtils.getSelectedElementFromDropDown(dataTestId).getText();
57 public static List<WebElement> byClass(String className) {
58 return GeneralUIUtils.getWebElementsListByContainsClassName(className);
61 public static WebElement byCssSelector(String css) {
62 return GeneralUIUtils.getDriver().findElement(By.cssSelector(css));
65 public static List<String> tableHeaderValuesByTestId(String tableId) {
66 return tableValuesById(tableId, "thead", "th").get(0);
69 public static List<List<String>> tableBodyValuesByTestId(String tableId) {
70 return tableValuesById(tableId, "tbody", "td");
73 private static List<WebElement> rowsByTableId(String tableId,String section, String column) {
75 return GeneralUIUtils.getElemenetsFromTable(By.xpath("//table[@data-tests-id=\"" + tableId + "\"]/" + section + "/tr"));
76 } catch (Exception var2) {
81 private static List<List<String>> tableValuesById(String tableId, String section, String column) {
82 List<WebElement> rows = rowsByTableId(tableId, section, column);
84 List<List<String>> tableContent = new ArrayList<List<String>>();
85 for(WebElement row:rows) {
86 List<WebElement> columns = row.findElements(By.xpath(column));
87 tableContent.add(GeneralUIUtils.getWebElementListText(columns));