aboutsummaryrefslogtreecommitdiffstats
path: root/vid-automation/src/main/java/vid/automation/test/sections/SearchExistingPage.java
blob: 5fc4894e9e9d0c141c7bef44e500542198d3de75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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;


/**
 * Created by pickjonathan on 10/07/2017.
 */

public class SearchExistingPage extends VidBasePage {

    public SearchExistingPage() {}

    public void selectSearchById(){
        selectSearchBy(Constants.EditExistingInstance.SERVICE_INSTANCE_ID);
    }

    public void selectSearchByName(){
        selectSearchBy(Constants.EditExistingInstance.SERVICE_INSTANCE_NAME);
    }

    public void selectSearchBy(String searchTypeOptionText) {
        boolean findAndWaitByText = GeneralUIUtils.findAndWaitByText(Constants.EditExistingInstance.SELECT_SERVICE_INSTANCE, 30);
        Assert.assertTrue(findAndWaitByText);
        GeneralUIUtils.clickOnElementByText(Constants.EditExistingInstance.SELECT_SERVICE_INSTANCE, 30);

        boolean isSearchByIdAvailable = GeneralUIUtils.findAndWaitByText(searchTypeOptionText, 30);
        Assert.assertTrue(isSearchByIdAvailable);
        GeneralUIUtils.clickOnElementByText(searchTypeOptionText, 30);
    }

    public void searchForInstanceByUuid(String uuid) {
        selectSearchById();
        startSearchByInstanceIdentifier(uuid);
    }

    private void startSearchByInstanceIdentifier(String text) {
        WebElement textInputWebElement = GeneralUIUtils.getWebElementByTestID(Constants.EditExistingInstance.SEARCH_FOR_EXISTING_INSTANCES_INPUT, 30);
        Assert.assertTrue(textInputWebElement != null);
        textInputWebElement.sendKeys(text);
        clickSubmitButton();
    }

    public void searchForInstanceByName(String name) {
        selectSearchByName();
        startSearchByInstanceIdentifier(name);
    }

    public void checkForEditButtons() {
        boolean isDeleteVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.DELETE_VNF_BTN, 30);
        Assert.assertFalse(isDeleteVisible);

        boolean isAddVnfModuleVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.ADD_VNF_MODULE_DROPDOWN, 30);
        Assert.assertFalse(isAddVnfModuleVisible);

        boolean isAddCustomVnfModuleVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.ADD_CUSTOM_VNF_MODULE_DROPDOWN, 30);
        Assert.assertFalse(isAddCustomVnfModuleVisible);

        boolean isAddCustomVolumeGroupVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.ADD_CUSTOM_VOLUME_GROUP, 30);
        Assert.assertFalse(isAddCustomVolumeGroupVisible);

        boolean isAddVolumeGroupVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.ADD_VOLUME_GROUP, 30);
        Assert.assertFalse(isAddVolumeGroupVisible);

        boolean isDeleteVfModuleVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.DELETE_VF_MODULE, 30);
        Assert.assertFalse(isDeleteVfModuleVisible);

        boolean isDeleteVnfGroupVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.DELETE_VNF_VOLUME_GROUP, 30);
        Assert.assertFalse(isDeleteVnfGroupVisible);

        boolean isDeleteNetworkVisible = GeneralUIUtils.waitForElementInVisibilityByTestId(Constants.EditExistingInstance.DELETE_NETWORK);
        Assert.assertFalse(isDeleteNetworkVisible);
    }
}