1 package vid.automation.test.sections;
3 import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
4 import org.openqa.selenium.By;
5 import org.openqa.selenium.WebElement;
6 import org.openqa.selenium.support.ui.ExpectedConditions;
7 import org.openqa.selenium.support.ui.WebDriverWait;
8 import vid.automation.test.infra.Get;
11 import java.util.stream.Collectors;
13 import static org.hamcrest.CoreMatchers.is;
14 import static org.hamcrest.MatcherAssert.assertThat;
16 public abstract class InstantiationStatusPage extends VidBasePage {
18 public static final String refreshButtonId = "refresh-btn";
20 public static String getWebTrTdSpanElementByParentID(WebElement tr, String id, int timeout) {
21 return tr.findElements(By.xpath(".//*[@id='" + id + "']//span")).get(0).getText();
24 public static int getNumberOfTableRows(int timeout){
25 WebDriverWait wait = waitUntilDriverIsReady(timeout);
26 return wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("//*[table]//tbody/tr"))).size();
29 public static WebElement assertInstantiationStatusRow(String spanIdSelector, Map<String, String> fieldsIdsAndExpected) {
31 WebElement newTrRow = getInstantiationStatusRow(spanIdSelector);
32 final Map<String, String> fieldIdAndActual = fieldsIdsAndExpected.entrySet().stream()
33 .collect(Collectors.toMap(
35 kv -> getWebTrTdSpanElementByParentID(newTrRow, kv.getKey(), 1)
38 assertThat("failed comparing spanIdSelector " + spanIdSelector, fieldIdAndActual, is(fieldsIdsAndExpected));
41 } catch (Exception e) {
42 throw new RuntimeException("error while assertInstantiationStatusRow with: String spanIdSelector=" +
43 spanIdSelector + ", fieldsIdsAndExpected=" + fieldsIdsAndExpected, e);
47 public static WebElement getInstantiationStatusRow(String spanIdSelector) {
48 GeneralUIUtils.ultimateWait();
49 return Get.byXpath("//*[@id='" + spanIdSelector + "']/parent::*/parent::*/parent::*", 0);
52 public static void clickRefreshButton() {
53 WebDriverWait wait = waitUntilDriverIsReady(0);
54 wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@id='"+ refreshButtonId + "']"))).click();
55 GeneralUIUtils.ultimateWait();