import com.aventstack.extentreports.Status;
import org.junit.Assert;
-import org.openecomp.sdc.ci.tests.execute.setup.ExtentTestActions;
-import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils;
-import org.openqa.selenium.By;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.WebElement;
+import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions;
+import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
+import org.openqa.selenium.*;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import vid.automation.test.Constants;
+import vid.automation.test.Constants.ViewEdit;
import vid.automation.test.infra.*;
import java.io.IOException;
import java.util.List;
import java.util.function.Function;
-import static org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils.getDriver;
+import static java.util.stream.Collectors.toMap;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.onap.sdc.ci.tests.utilities.GeneralUIUtils.getDriver;
+import static org.testng.Assert.assertEquals;
public class VidBasePage {
+
public VidBasePage setInstanceName(String name) {
setInputText(Constants.INSTANCE_NAME_SELECT_TESTS_ID, name);
return this;
public String getInputValue(String inputTestsId) {
WebElement instanceNameInput = GeneralUIUtils.getInputElement(inputTestsId);
- String value =instanceNameInput.getAttribute("value");
- return value;
+ return instanceNameInput.getAttribute("value");
}
public String generateInstanceName(String prefix) {
public VidBasePage clickDeployServiceButtonByServiceUUID(String serviceUUID) {
Input.replaceText(serviceUUID, Constants.BROWSE_SEARCH);
+ GeneralUIUtils.ultimateWait();
String elementTestId = Constants.DEPLOY_BUTTON_TESTS_ID_PREFIX + serviceUUID;
GeneralUIUtils.clickOnElementByTestId(elementTestId, 30);
GeneralUIUtils.ultimateWait();
return this;
}
+ public boolean isModelWithGivenServiceUUIDVisible(String serviceUUID) {
+ String elementTestId = Constants.DEPLOY_BUTTON_TESTS_ID_PREFIX + serviceUUID;
+ try {
+ GeneralUIUtils.getWebElementByTestID(elementTestId, 10);
+ GeneralUIUtils.ultimateWait();
+ } catch (TimeoutException te) {
+ return false;
+ }
+ return true;
+ }
+
public void screenshotDeployDialog(String serviceUUID) {
try {
GeneralUIUtils.ultimateWait();
return this;
}
+ public VidBasePage clickButtonByTestId(String testId) {
+ GeneralUIUtils.clickOnElementByTestId(testId);
+ return this;
+ }
+
public VidBasePage clickCommitCloseButton() {
GeneralUIUtils.clickOnElementByTestId(Constants.COMMIT_CLOSE_BUTTON_ID, 30);
return this;
return this;
}
-
public VidBasePage selectLcpRegion(String lcpRegion) {
- SelectOption.byValue(lcpRegion, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
+ return selectLcpRegion(lcpRegion, "AIC");
+ }
+
+ public VidBasePage selectLcpRegion(String lcpRegion, String cloudOwner) {
+ GeneralUIUtils.ultimateWait();
+ String visibleText = (Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive()) ?
+ String.format("%s (%s)", lcpRegion, cloudOwner) : lcpRegion;
+ SelectOption.byTestIdAndVisibleText(visibleText, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
+ return this;
+ }
+
+ public VidBasePage selectLineOfBusiness(String lineOfBusines) {
+ GeneralUIUtils.ultimateWait();
+ SelectOption.byValue(lineOfBusines, Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID);
return this;
}
public VidBasePage selectTenant(String tenant) {
+ GeneralUIUtils.ultimateWait();
SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID);
return this;
}
return this;
}
- public VidBasePage selectLineOfBusiness(String lob) {
- SelectOption.byValue(lob, Constants.OwningEntity.LOB_SELECT_TEST_ID);
- return this;
- }
public void assertButtonState(String dataTestId, boolean shouldBeEnabled) {
assertButtonStateInternal(dataTestId, shouldBeEnabled,
Assert.assertEquals(expectedText, alertText);
Click.acceptAlert();
}
- public void goToIframe() {
+ public static void goToIframe() {
final long start = System.currentTimeMillis();
goOutFromIframe();
GeneralUIUtils.ultimateWait();
System.out.println("ultimateWait waited " + (System.currentTimeMillis() - start));
- final WebDriver iframeReady = new WebDriverWait(getDriver(), 10).until(
+ final WebDriver iframeReady = new WebDriverWait(getDriver(), 20).until(
ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.tagName("iframe"))
);
Assert.assertNotNull("failed going into iframe", iframeReady);
System.out.println("ultimateWait waited " + (System.currentTimeMillis() - start2));
}
- public void goOutFromIframe(){
+ public static void goOutFromIframe(){
getDriver().switchTo().defaultContent();
}
+ public void verifyOpenOldViewEdit(String serviceInstanceName, String serviceInstanceId, boolean openShouldBeEnabled, boolean checkPortMirroring, boolean checkAddVnf) {
+ InstantiationStatusPage.checkMenuItem(serviceInstanceName, Constants.InstantiationStatus.CONTEXT_MENU_HEADER_OPEN_ITEM, openShouldBeEnabled, contextMenuOpen -> {
+ Click.byTestId(contextMenuOpen);
+ VidBasePage.goOutFromIframe();
+ GeneralUIUtils.ultimateWait();
+ Wait.byText("View/Edit Service Instance");
+ if (serviceInstanceId != null) {
+ Wait.byText(serviceInstanceId);
+ }
+ Wait.byText(serviceInstanceName);
+
+ if (checkPortMirroring) {
+ Wait.byText("Add node instance");
+ Wait.byText(ViewEdit.COMMON_PORT_MIRRORING_PORT_NAME);
+ }
+
+ if (checkAddVnf) {
+ // Validate bug fix - we open old popup in view/edit
+ Click.byTestId("addVNFButton");
+ Click.byTestId("addVNFOption-2017-488_PASQUALE-vPE 0");
+ assertThat(Get.byTestId("create-modal-title").getText(), containsString("a la carte"));
+ Click.byTestId("cancelButton");
+ //end of bug fix validation
+ }
+
+ screenshotDeployDialog("view-edit-" + serviceInstanceName);
+ SideMenu.navigateToMacroInstantiationStatus();
+ });
+ }
public static WebDriverWait waitUntilDriverIsReady(int time) {
return new WebDriverWait(getDriver(), (long)time);
}
+ public String getReduxState() {
+ final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver();
+ String reduxState = (String)javascriptExecutor.executeScript("return window.sessionStorage.getItem('reduxState');");
+ System.out.println(reduxState);
+ return reduxState;
+ }
+
+ public void setReduxState(String state) {
+ final JavascriptExecutor javascriptExecutor = (JavascriptExecutor) GeneralUIUtils.getDriver();
+ String script = String.format("window.sessionStorage.setItem('reduxState', '%s');", state);
+ System.out.println("executing script:");
+ System.out.println(script);
+ javascriptExecutor.executeScript(script);
+ }
}