2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2019 Nordix Foundation
4 * ================================================================================
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 * SPDX-License-Identifier: Apache-2.0
17 * ============LICENSE_END=========================================================
20 package org.openecomp.sdc.ci.tests.pages;
22 import static org.hamcrest.Matchers.equalToIgnoringCase;
23 import static org.hamcrest.core.Is.is;
24 import static org.junit.Assert.assertThat;
25 import static org.openecomp.sdc.ci.tests.pages.ResourceCreatePage.XpathSelector.FORM_LIFE_CYCLE_STATE;
27 import org.openecomp.sdc.ci.tests.datatypes.LifeCycleStateEnum;
28 import org.openecomp.sdc.ci.tests.utilities.LoaderHelper;
29 import org.openecomp.sdc.ci.tests.utilities.NotificationHelper;
30 import org.openecomp.sdc.ci.tests.utilities.NotificationHelper.NotificationType;
31 import org.openqa.selenium.By;
32 import org.openqa.selenium.WebDriver;
33 import org.openqa.selenium.WebElement;
34 import org.openqa.selenium.support.ui.ExpectedConditions;
35 import org.slf4j.Logger;
36 import org.slf4j.LoggerFactory;
39 * Handles the Resource Create Page UI actions
41 public class ResourceCreatePage extends AbstractPageObject {
43 private static final Logger LOGGER = LoggerFactory.getLogger(ResourceCreatePage.class);
44 private final LoaderHelper loaderHelper;
45 private final NotificationHelper notificationHelper;
46 private WebElement createBtn;
48 public ResourceCreatePage(final WebDriver webDriver, final LoaderHelper loaderHelper,
49 final NotificationHelper notificationHelper) {
51 this.loaderHelper = loaderHelper;
52 this.notificationHelper = notificationHelper;
57 public void isLoaded() {
58 LOGGER.debug("Waiting for element visibility with xpath '{}'", FORM_LIFE_CYCLE_STATE.getXpath());
59 final WebElement lifeCycleState = waitForElementVisibility(FORM_LIFE_CYCLE_STATE.getXpath());
60 assertThat("Life cycle state should be as expected",
61 lifeCycleState.getText(), is(equalToIgnoringCase(LifeCycleStateEnum.IN_DESIGN.getValue())));
63 .until(ExpectedConditions.elementToBeClickable(By.xpath(XpathSelector.CREATE_BTN.getXpath())));
67 * Creates the resource and wait for success notification.
69 public void createResource() {
71 loaderHelper.waitForLoader(60);
72 notificationHelper.waitForNotification(NotificationType.SUCCESS, 60);
76 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
78 public enum XpathSelector {
79 CREATE_BTN("create/save", "//button[@data-tests-id='%s']"),
80 FORM_LIFE_CYCLE_STATE("formlifecyclestate", "//span[@data-tests-id='%s']");
82 private final String id;
83 private final String xpathFormat;
85 XpathSelector(final String id, final String xpathFormat) {
87 this.xpathFormat = xpathFormat;
90 public String getId() {
94 public String getXpath() {
95 return String.format(xpathFormat, id);