org.onap migration
[vid.git] / vid-automation / src / main / java / vid / automation / test / sections / ViewEditPage.java
1 package vid.automation.test.sections;
2
3 import org.junit.Assert;
4 import org.openecomp.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.Get;
9 import vid.automation.test.infra.SelectOption;
10 import vid.automation.test.infra.Wait;
11
12 /**
13  * Created by itzikliderman on 13/06/2017.
14  */
15 public class ViewEditPage extends VidBasePage {
16     public ViewEditPage selectNodeInstanceToAdd(String vnfName) {
17         selectFromDropdownByTestId(Constants.ViewEdit.VNF_OPTION_TEST_ID_PREFIX + vnfName,
18                 Constants.ViewEdit.ADD_VNF_BUTTON_TEST_ID);
19         return this;
20     }
21
22     public ViewEditPage selectVolumeGroupToAdd(String volumeGroupName) {
23         selectFromDropdownByTestId(Constants.ViewEdit.VOLUME_GROUP_OPTION_TEST_ID_PREFIX + volumeGroupName,
24                 Constants.ViewEdit.ADD_VOLUME_GROUP_BUTTON_TEST_ID);
25         return this;
26     }
27
28     public ViewEditPage selectFromDropdownByText(String itemText, String dropdownButtonTestId) {
29         GeneralUIUtils.clickOnElementByTestId(dropdownButtonTestId, 30);
30         GeneralUIUtils.clickOnElementByText(itemText, 30);
31         return this;
32     }
33
34     public ViewEditPage selectFromDropdownByTestId(String itemTestId, String dropdownButtonTestId) {
35         GeneralUIUtils.clickOnElementByTestId(dropdownButtonTestId, 60);
36         Assert.assertTrue(String.format(Constants.ViewEdit.OPTION_IN_DROPDOWN_NOT_EXISTS,dropdownButtonTestId,"Add network instance"),GeneralUIUtils.getWebElementByTestID(itemTestId) != null );
37         GeneralUIUtils.clickOnElementByTestId(itemTestId, 60);
38         return this;
39     }
40
41     public ViewEditPage selectProductFamily(String productFamily){
42         SelectOption.byValue(productFamily, Constants.ViewEdit.PRODUCT_FAMILY_SELECT_TESTS_ID);
43         return this;
44     }
45
46     public ViewEditPage selectLCPRegion(String lcpRegion){
47         SelectOption.byValue(lcpRegion, Constants.ViewEdit.LCP_REGION_SELECT_TESTS_ID);
48         return this;
49     }
50
51     public ViewEditPage setLegacyRegion(String legacyRegionName){
52         setInputText(Constants.ViewEdit.LEGACY_REGION_INPUT_TESTS_ID, legacyRegionName);
53         return this;
54     }
55
56     public ViewEditPage selectTenant(String tenant){
57         SelectOption.byValue(tenant, Constants.ViewEdit.TENANT_SELECT_TESTS_ID);
58         return this;
59     }
60
61     public VidBasePage clickActivateButton() {
62         GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.ACTIVATE_BUTTON_TEST_ID, 60);
63         return this;
64     }
65
66     public WebElement getPnf(String pnfName) {
67         WebElement pnfElement = Get.byClassAndText("tree-node", "PNF: " + pnfName);
68         Assert.assertNotNull("Pnf "+ pnfName +" not found under service instance", pnfElement);
69         return pnfElement;
70     }
71
72     public ViewEditPage clickDissociatePnfButton(String pnfName) {
73         WebElement pnfToDissociate = getPnf(pnfName);
74         WebElement dissociateBtn = pnfToDissociate.findElement(By.className(Constants.ViewEdit.DISSOCIATE_BTN_CLASS));
75         Assert.assertNotNull("Dissociate button not found for pnf " + pnfName, dissociateBtn);
76         dissociateBtn.click();
77         return this;
78     }
79
80     public VidBasePage clickDeactivateButton() {
81         GeneralUIUtils.clickOnElementByTestId(Constants.ViewEdit.DEACTIVATE_BUTTON_TEST_ID, 30);
82         return this;
83     }
84 }