diff options
author | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
---|---|---|
committer | Ofir Sonsino <os0695@att.com> | 2018-01-31 17:19:00 +0200 |
commit | 1cfb08779ea0e00be69e072a940b3063e049fe6b (patch) | |
tree | 6602a900387c8393ed0dcd81c0539381632903c6 /vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java | |
parent | 2f20b001b9243e0f8b44aecc768ec265fd538732 (diff) |
org.onap migration
Change-Id: I52f0b2851f2c765752b6d21f49b32136d7d72a3d
Issue-ID: VID-86
Signed-off-by: Ofir Sonsino <os0695@att.com>
Diffstat (limited to 'vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java')
-rw-r--r-- | vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java new file mode 100644 index 000000000..6e0367edd --- /dev/null +++ b/vid-automation/src/main/java/vid/automation/test/sections/VidBasePage.java @@ -0,0 +1,132 @@ +package vid.automation.test.sections; + +import org.junit.Assert; +import org.openecomp.sdc.ci.tests.utilities.GeneralUIUtils; +import org.openqa.selenium.WebElement; +import vid.automation.test.Constants; +import vid.automation.test.infra.Click; +import vid.automation.test.infra.SelectOption; +import vid.automation.test.infra.Wait; + +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +public class VidBasePage { + + public VidBasePage setInstanceName(String name) { + setInputText(Constants.INSTANCE_NAME_SELECT_TESTS_ID, name); + return this; + } + + public void generateAndSetInstanceName(String prefix) { + String instanceName = generateInstanceName(prefix); + setInstanceName(instanceName); + } + + public VidBasePage setInputText(String inputTestsId, String text) { + WebElement instanceNameInput = GeneralUIUtils.getInputElement(inputTestsId); + instanceNameInput.sendKeys(text); + return this; + } + + public String generateInstanceName(String prefix) { + SimpleDateFormat sdf = new SimpleDateFormat(Constants.BrowseASDC.DATE_FORMAT); + Date now = Calendar.getInstance().getTime(); + return prefix + sdf.format(now); + } + + public VidBasePage selectServiceTypeByName(String serviceType) { + SelectOption.byTestIdAndVisibleText(serviceType, Constants.SERVICE_TYPE_SELECT_TESTS_ID); + return this; + } + + public static void selectSubscriberById(String subscriberId) { + SelectOption.byValue(subscriberId, Constants.SUBSCRIBER_NAME_SELECT_TESTS_ID); + } + + public VidBasePage selectProductFamily(String productFamily) { + SelectOption.byValue(productFamily, Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID); + return this; + } + + public VidBasePage selectSuppressRollback(String shouldSuppress) { + SelectOption.byTestIdAndVisibleText(shouldSuppress, Constants.SUPPRESS_ROLLBACK_SELECT_TESTS_ID); + return this; + } + + public VidBasePage clickDeployServiceButtonByServiceUUID(String serviceUUID) { + setInputText(Constants.BROWSE_SEARCH, serviceUUID); + String elementTestId = Constants.DEPLOY_BUTTON_TESTS_ID_PREFIX + serviceUUID; + GeneralUIUtils.clickOnElementByTestId(elementTestId, 30); + GeneralUIUtils.ultimateWait(); + return this; + } + + public VidBasePage clickEditViewByInstanceId(String instanceId) { + String elementTestId = Constants.VIEW_EDIT_TEST_ID_PREFIX + instanceId; + GeneralUIUtils.clickOnElementByTestId(elementTestId, 100); + GeneralUIUtils.ultimateWait(); + return this; + } + + public VidBasePage clickSubmitButton() { + GeneralUIUtils.clickOnElementByText(Constants.SUBMIT_BUTTON_TEXT, 30); + return this; + } + + public VidBasePage clickCancelButton() { + Click.byId(Constants.generalCancelButtonId); + return this; + } + + + public VidBasePage clickConfirmButton() { + GeneralUIUtils.clickOnElementByTestId(Constants.CONFIRM_BUTTON_TESTS_ID, 30); + return this; + } + + public VidBasePage clickCloseButton() { + GeneralUIUtils.clickOnElementByText(Constants.CLOSE_BUTTON_TEXT, 30); + return this; + } + + public VidBasePage selectLcpRegion(String lcpRegion) { + SelectOption.byValue(lcpRegion, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID); + return this; + } + + public VidBasePage selectTenant(String tenant) { + SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID); + return this; + } + + public VidBasePage selectAicZone(String aicZone) { + SelectOption.byValue(aicZone, Constants.ViewEdit.AIC_ZONE_TEST_ID); + return this; + } + + public void assertButtonState(String dataTestId, boolean shouldBeEnabled) { + GeneralUIUtils.ultimateWait(); + WebElement webElement = GeneralUIUtils.getWebElementByTestID(dataTestId, 60); + boolean enabledElement= webElement.getAttribute("disabled")==null?true:false; + if(shouldBeEnabled) { + Assert.assertTrue(String.format(Constants.ViewEdit.ENABLE_ERROR_MESSAGE,dataTestId), enabledElement); + }else{ + Assert.assertFalse(String.format(Constants.ViewEdit.DISABLE_ERROR_MESSAGE,dataTestId),enabledElement); + } + + } + public VidBasePage assertMsoRequestModal(String statusMsg) { + boolean waitForTextResult = Wait.waitByClassAndText("status", statusMsg, 60); + Assert.assertTrue(statusMsg + " message didn't appear on time", waitForTextResult); + + return this; + } + + public VidBasePage refreshPage() { + GeneralUIUtils.getDriver().navigate().refresh(); + return this; + } + +} |