vid-automation selenium tests
[vid.git] / vid-automation / src / main / java / vid / automation / test / sections / ServiceProxyPage.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.WebElement;
6 import vid.automation.test.Constants;
7 import vid.automation.test.infra.SelectOption;
8
9 import static org.hamcrest.core.Is.is;
10
11 public class ServiceProxyPage extends VidBasePage {
12
13     public ServiceProxyPage chooseSource(String source){
14         SelectOption.byTestIdAndVisibleText(source, Constants.ConfigurationCreation.SOURCE_DROPDOWN_TEST_ID);
15         return this;
16     }
17     public ServiceProxyPage chooseSourceServiceType(String sourceServiceType){
18         SelectOption.byTestIdAndVisibleText(sourceServiceType, "sourceServiceType");
19         GeneralUIUtils.ultimateWait();
20         return this;
21     }
22     public ServiceProxyPage chooseCollectorServiceType(String collectorServiceType){
23         SelectOption.byTestIdAndVisibleText(collectorServiceType, "collectorServiceType");
24         GeneralUIUtils.ultimateWait();
25         return this;
26     }
27     public ServiceProxyPage chooseCollector(String collector){
28         GeneralUIUtils.ultimateWait();
29         SelectOption.byTestIdAndVisibleText(collector, Constants.ConfigurationCreation.COLLECTOR_DROPDOWN_TEST_ID);
30         return this;
31     }
32     public ServiceProxyPage clickCreateButton() {
33         GeneralUIUtils.clickOnElementByTestId(Constants.ConfigurationCreation.CREATE_BUTTON_TEST_ID, 60);
34         return this;
35     }
36
37     public ServiceProxyPage clickDeleteConfigurationButton() {
38         GeneralUIUtils.clickOnElementByTestId(Constants.DELETE_CONFIGURATION_BUTTON, 60);
39         return this;
40     }
41
42     public ServiceProxyPage assertDeleteConfigurationButtonExists(boolean shouldExist){
43
44         if (shouldExist) {
45             WebElement selectedV = GeneralUIUtils.getWebElementByTestID(Constants.DELETE_CONFIGURATION_BUTTON, 3);
46             Assert.assertThat(selectedV != null, is(shouldExist));
47             Assert.assertThat(selectedV.isDisplayed(), is(shouldExist));
48         } else {
49             boolean webElementExistByTestId = GeneralUIUtils.isWebElementExistByTestId(Constants.DELETE_CONFIGURATION_BUTTON);
50             Assert.assertThat(webElementExistByTestId, is(shouldExist));
51         }
52         return this;
53     }
54
55     public void assertSourceModelName(String sourceName){
56         String displayedSourceName= getTextByTestID(Constants.ConfigurationCreation.SOURCE_INSTANCE_NAME_TEST_ID);
57         Assert.assertEquals("The displayed source name is not correct", sourceName+" i", displayedSourceName);
58     }
59
60     public void assertCollectorModelName(String collectorName) {
61         String displayedCollectorName = getTextByTestID(Constants.ConfigurationCreation.COLLECTOR_INSTANCE_NAME_TEST_ID);
62         Assert.assertEquals("The displayed collector name is not correct", collectorName+"i", displayedCollectorName);
63     }
64
65     public void assertNoResultRequirementsDropDown(String msgTestId, String resourceType){
66         String noResultText = GeneralUIUtils.getWebElementByTestID(msgTestId, 60).getText();
67         Assert.assertEquals("The error message no instance in DropDown is not match","No "+resourceType+" instances found.",noResultText);
68     }
69     public ServiceProxyPage clickInfoButton(String infoButtonTestId) {
70         GeneralUIUtils.clickOnElementByTestId(infoButtonTestId, 90);
71         return this;
72     }
73
74
75     public ServiceProxyPage assertSelectedInstanceIcon(String SelectedIconTestId){
76         WebElement selectedV = GeneralUIUtils.getWebElementByTestID(SelectedIconTestId, 90);
77         Assert.assertTrue(selectedV != null);
78         String selectedVClass = selectedV.getAttribute("class");
79         Assert.assertTrue(selectedVClass.contains("valid-large"));
80         return this;
81     }
82
83     public ServiceProxyPage clickActivateDeactivateButton() {
84         GeneralUIUtils.clickOnElementByTestId(Constants.ACTIVATE_DEACTIVATE_BUTTON, 60);
85         return this;
86     }
87
88     public ServiceProxyPage clickEnableDisableButton(){
89         GeneralUIUtils.clickOnElementByTestId(Constants.ENABLE_DISABLE_BUTTON, 60);
90         return this;
91     }
92 }