From 13cfdbd3639281afeb19e2f41f8751964d1eb58a Mon Sep 17 00:00:00 2001 From: Ittay Stern Date: Mon, 23 Sep 2019 16:30:34 +0300 Subject: Take more Change-management Selenium screenshots Issue-ID: VID-397 Change-Id: I9b925068346dd3ebb6665a83b0a1b7876193c2ff Signed-off-by: Ittay Stern --- .../automation/test/test/ChangeManagementTest.java | 25 ++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'vid-automation/src/main') diff --git a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java index ed0180dd9..0f75df67e 100644 --- a/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java +++ b/vid-automation/src/main/java/vid/automation/test/test/ChangeManagementTest.java @@ -3,6 +3,7 @@ package vid.automation.test.test; import static java.util.Collections.emptyMap; import static net.javacrumbs.jsonunit.JsonMatchers.jsonEquals; +import static org.apache.commons.lang3.exception.ExceptionUtils.rethrow; import static org.hamcrest.CoreMatchers.containsString; import static org.hamcrest.CoreMatchers.everyItem; import static org.hamcrest.CoreMatchers.hasItem; @@ -18,9 +19,11 @@ import static org.onap.vid.api.BaseApiTest.getResourceAsString; import static vid.automation.test.infra.Features.FLAG_FLASH_REDUCED_RESPONSE_CHANGEMG; import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; +import com.aventstack.extentreports.Status; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.Ints; +import java.io.IOException; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; @@ -34,6 +37,7 @@ import net.javacrumbs.jsonunit.core.Option; import org.json.JSONException; import org.junit.Assert; import org.onap.sdc.ci.tests.datatypes.UserCredentials; +import org.onap.sdc.ci.tests.execute.setup.ExtentTestActions; import org.onap.sdc.ci.tests.utilities.GeneralUIUtils; import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; import org.onap.simulator.presetGenerator.presets.aai.PresetBaseAAICustomQuery; @@ -44,6 +48,7 @@ import org.openqa.selenium.remote.RemoteWebElement; import org.openqa.selenium.support.ui.Select; import org.skyscreamer.jsonassert.JSONAssert; import org.skyscreamer.jsonassert.JSONCompareMode; +import org.testng.ITestResult; import org.testng.annotations.AfterClass; import org.testng.annotations.AfterMethod; import org.testng.annotations.BeforeClass; @@ -330,6 +335,7 @@ public class ChangeManagementTest extends VidBaseTestCase { GeneralUIUtils.ultimateWait(); WebElement cancelPendingConfirmationMessage = Get.byTestId("btn-cancel-workflow"); assertThat(cancelPendingConfirmationMessage.getText(), containsString("Are you sure you want to delete workflow")); + screenshot("delete workflow"); } private void clickAndAssertClickOnCancelWorkflowButtonOnPendingPopUp() { @@ -343,6 +349,7 @@ public class ChangeManagementTest extends VidBaseTestCase { Click.byClass("pull-right modal-close"); } } + screenshot("cancel workflow"); Click.byClassAndVisibleText("btn", "OK"); } @@ -386,7 +393,10 @@ public class ChangeManagementTest extends VidBaseTestCase { } @AfterMethod(alwaysRun = true) - public void closeForm() { + public void screenshotAndCloseForm(ITestResult testResult) { + + screenshot(testResult.getName() + (testResult.isSuccess() ? "" : " FAIL")); + // Tries closing left-out popups, if any // If none -- catch clause will swallow the exception try { @@ -399,6 +409,14 @@ public class ChangeManagementTest extends VidBaseTestCase { Wait.modalToDisappear(); } + protected void screenshot(String testName) { + try { + ExtentTestActions.addScreenshot(Status.INFO, "ChangeManagementTest." + testName, testName); + } catch (IOException e) { + rethrow(e); + } + } + @Test public void testWorkflowVNFInPlaceSoftwareUpdateShows3Fields() { @@ -575,6 +593,7 @@ public class ChangeManagementTest extends VidBaseTestCase { } private void assertThatVidToPortalCallbackDataIsOk(String workflowName, Map workflowParams) { + screenshot("submit to scheduler"); Assert.assertTrue(Get.byId(Constants.generalSubmitButtonId).isEnabled()); Click.byId(Constants.generalSubmitButtonId); @@ -778,7 +797,7 @@ public class ChangeManagementTest extends VidBaseTestCase { Wait.modalToDisappear(); } - @Test(enabled = false) + @Test public void testSuccessCancelPendingWorkflow() { ChangeManagementPage.openChangeManagementPage(); Wait.angularHttpRequestsLoaded(); @@ -788,6 +807,7 @@ public class ChangeManagementTest extends VidBaseTestCase { Assert.assertTrue(Exists.modal()); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.pendingModalHeaderId)); Assert.assertTrue(Exists.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass)); + screenshot("pendingModalCancelWorkflow"); Click.byClass(Constants.ChangeManagement.pendingModalCancelWorkflowButtonClass); Wait.angularHttpRequestsLoaded(); @@ -795,6 +815,7 @@ public class ChangeManagementTest extends VidBaseTestCase { Assert.assertTrue(Exists.modal()); Assert.assertTrue(Exists.byId(Constants.ChangeManagement.alertModalHeaderId)); Assert.assertTrue(Exists.byClassAndText(Constants.generalModalTitleClass, "Success")); + screenshot("successCancelWorkflow"); Click.byClass(Constants.generalCloseModalButtonClass); Wait.modalToDisappear(); //TODO check the workflow deleted from table/changed to deleted action -- cgit 1.2.3-korg