2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2021 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.onap.sdc.frontend.ci.tests.pages;
22 import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.FORM_LIFE_CYCLE_STATE;
23 import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.ACTION_BUTTON_DIV;
24 import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.LIFECYCLE_STATE_DIV;
25 import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.MAIN_DIV;
26 import static org.onap.sdc.frontend.ci.tests.pages.ResourceWorkspaceTopBarComponent.XpathSelector.VERSION_CONTAINER_DIV;
27 import static org.onap.sdc.frontend.ci.tests.pages.ServiceCreatePage.XpathSelector.CREATE_BTN;
29 import lombok.AllArgsConstructor;
31 import org.openqa.selenium.By;
32 import org.openqa.selenium.WebDriver;
33 import org.openqa.selenium.WebElement;
34 import org.slf4j.Logger;
35 import org.slf4j.LoggerFactory;
38 * Represents the top bar component of the a resource workspace, which contains the resource version, status, progress bar, and some action buttons.
40 public class ResourceWorkspaceTopBarComponent extends AbstractPageObject {
42 private static final Logger LOGGER = LoggerFactory.getLogger(ResourceWorkspaceTopBarComponent.class);
44 private WebElement wrappingElement;
45 private WebElement lifecycleStateDiv;
46 private WebElement versionContainerDiv;
47 private WebElement actionButtonsDiv;
49 public ResourceWorkspaceTopBarComponent(final WebDriver webDriver) {
54 public void isLoaded() {
55 LOGGER.debug("Waiting for element visibility with xpath '{}'", MAIN_DIV.getXpath());
56 wrappingElement = waitForElementVisibility(By.xpath(MAIN_DIV.getXpath()), 5);
57 lifecycleStateDiv = wrappingElement.findElement(By.xpath(LIFECYCLE_STATE_DIV.getXpath()));
58 versionContainerDiv = wrappingElement.findElement(By.xpath(VERSION_CONTAINER_DIV.getXpath()));
59 actionButtonsDiv = wrappingElement.findElement(By.xpath(ACTION_BUTTON_DIV.getXpath()));
62 public void clickOnCreate() {
63 waitToBeClickable(CREATE_BTN.getXpath()).click();
66 public String getLifecycleState() {
67 return lifecycleStateDiv.findElement(By.xpath(FORM_LIFE_CYCLE_STATE.getXpath())).getText();
71 * Enum that contains identifiers and xpath expressions to elements related to the enclosing page object.
74 public enum XpathSelector {
75 MAIN_DIV("sdc-workspace-top-bar", "//div[@class='%s']"),
76 LIFECYCLE_STATE_DIV("lifecycle-state", "//div[@class='%s']"),
77 VERSION_CONTAINER_DIV("version-container", "//div[@class='%s']"),
78 ACTION_BUTTON_DIV("sdc-workspace-top-bar-buttons", "//div[@class='%s']"),
79 CREATE_BTN("create/save", "//button[@data-tests-id='%s']"),
80 FORM_LIFE_CYCLE_STATE("formlifecyclestate", "//span[@data-tests-id='%s']");
83 private final String id;
84 private final String xpathFormat;
86 public String getXpath() {
87 return String.format(xpathFormat, id);