1 package vid.automation.test.sections;
3 import org.junit.Assert;
4 import org.onap.sdc.ci.tests.utilities.GeneralUIUtils;
5 import org.openqa.selenium.By;
6 import org.openqa.selenium.WebElement;
7 import vid.automation.test.Constants;
8 import vid.automation.test.infra.Features;
9 import vid.automation.test.infra.Get;
10 import vid.automation.test.infra.SelectOption;
12 import static org.hamcrest.core.Is.is;
15 * Created by itzikliderman on 13/06/2017.
17 public class ViewEditPage extends VidBasePage {
18 public ViewEditPage selectNodeInstanceToAdd(String vnfName) {
19 selectFromDropdownByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + vnfName,
20 Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID);
24 public ViewEditPage selectVfModuleToAdd(String vfModuleName) {
25 selectFromDropdownByTestId(Constants.ViewEdit.VF_MODULE_OPTION_TEST_ID_PREFIX + vfModuleName,
26 Constants.ViewEdit.ADD_VF_MODULE_BUTTON_TEST_ID);
30 public ViewEditPage clickResumeButton(String instanceName) {
31 //instanceName = "my_vfModule";
32 String instanceId = Constants.ViewEdit.VF_MODULE_RESUME_ID_PREFIX + instanceName;
33 checkIfExistResumeButton(instanceName,true);
34 GeneralUIUtils.clickOnElementByTestId(instanceId);
39 public ViewEditPage checkIfExistResumeButton(String instanceName, Boolean expected) {
40 //instanceName = "my_vfModule";
41 String instanceId = Constants.ViewEdit.VF_MODULE_RESUME_ID_PREFIX + instanceName;
42 WebElement resumeButton = GeneralUIUtils.getWebElementByTestID(instanceId, 30);
43 Assert.assertThat(resumeButton != null, is(expected));
47 public ViewEditPage selectVolumeGroupToAdd(String volumeGroupName) {
48 selectFromDropdownByTestId(Constants.ViewEdit.VOLUME_GROUP_OPTION_TEST_ID_PREFIX + volumeGroupName,
49 Constants.ViewEdit.ADD_VOLUME_GROUP_BUTTON_TEST_ID);
53 public ViewEditPage selectFromDropdownByText(String itemText, String dropdownButtonTestId) {
54 GeneralUIUtils.clickOnElementByTestId(dropdownButtonTestId, 30);
55 GeneralUIUtils.clickOnElementByText(itemText, 30);
59 public ViewEditPage selectNetworkToAdd(String networkName) {
60 selectFromDropdownByTestId(Constants.ViewEdit.NETWORK_OPTION_TEST_ID_PREFIX + networkName,
61 Constants.ViewEdit.ADD_NETWORK_BUTTON_TEST_ID);
65 public ViewEditPage selectProductFamily(String productFamily){
66 SelectOption.byValue(productFamily, Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID);
70 public ViewEditPage selectLcpRegion(String lcpRegion, String cloudOwner){
71 selectLcpRegion(lcpRegion);
72 if (Features.FLAG_1810_CR_ADD_CLOUD_OWNER_TO_MSO_REQUEST.isActive()) {
73 String selectedOption = SelectOption.getSelectedOption(Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
74 Assert.assertEquals(lcpRegion + " (" + cloudOwner.toUpperCase() + ")", selectedOption);
79 public ViewEditPage setLegacyRegion(String legacyRegionName){
80 setInputText(Constants.ViewEdit.LEGACY_REGION_INPUT_TESTS_ID, legacyRegionName);
84 public ViewEditPage selectTenant(String tenant){
85 SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID);
86 // GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.TENANT_SELECT_TESTS_ID, 60);
90 public VidBasePage clickActivateButton() {
91 GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID, 60);
95 public VidBasePage clickActivateFabricConfigurationButton() {
96 GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_FABRIC_CONFIGURATION_BUTTON_TEST_ID, 60);
99 public VidBasePage clickInfoButton() {
100 GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.INFOSERVICEBUTTON, 30);
104 public VidBasePage clickDeleteButton() {
105 GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.DELETESERVICEBUTTON, 3);
110 public WebElement getPnf(String pnfName) {
111 WebElement pnfElement = Get.byClassAndText("tree-node", "PNF: " + pnfName);
112 Assert.assertNotNull("Pnf "+ pnfName +" not found under service instance", pnfElement);
116 public ViewEditPage clickDissociatePnfButton(String pnfName) {
117 WebElement pnfToDissociate = getPnf(pnfName);
118 WebElement dissociateBtn = pnfToDissociate.findElement(By.className(Constants.ViewEdit.DISSOCIATE_BTN_CLASS));
119 Assert.assertNotNull("Dissociate button not found for pnf " + pnfName, dissociateBtn);
120 dissociateBtn.click();
124 public VidBasePage clickDeactivateButton() {
125 GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID, 30);
129 public ViewEditPage selectLineOfBusiness(String lineOfBusiness) {
131 SelectOption.selectFirstTwoOptionsFromMultiselectById(Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID);
132 } catch (InterruptedException e) {
136 //TODO multi SelectOption.byValue(lineOfBusiness, Constants.ViewEdit.LINE_OF_BUSINESS_SELECT_TESTS_ID);
140 public ViewEditPage selectPlatform(String platform) {
141 SelectOption.byValue(platform, Constants.OwningEntity.PLATFORM_SELECT_TEST_ID);