/src/test/java/it/page/ProjectSettingsPage.java
Java | 80 lines | 64 code | 14 blank | 2 comment | 2 complexity | 81d827e44a85b24b1b5c970ef5302728 MD5 | raw file
- package it.page;
- import com.atlassian.jira.pageobjects.pages.AbstractJiraPage;
- import com.atlassian.pageobjects.elements.ElementBy;
- import com.atlassian.pageobjects.elements.PageElement;
- import com.atlassian.pageobjects.elements.query.TimedCondition;
- import com.google.common.base.Function;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import javax.annotation.Nullable;
- /**
- */
- public class ProjectSettingsPage extends AbstractJiraPage {
- private final static String URI = "/plugins/servlet/project-config/%s/summary";
- private final String projectKey;
- @ElementBy(id = "summary-settings_heading")
- private PageElement projectSettings;
- public ProjectSettingsPage(String projectKey) {
- this.projectKey = projectKey;
- }
- @Override
- public TimedCondition isAt() {
- return projectSettings.timed().isPresent();
- }
- public String getUrl() {
- return String.format(URI, projectKey);
- }
- public boolean isJMCEnabled() {
- return this.driver.elementIsVisible(By.id("project-config-jmc-change-IS-ON"));
- }
- public String getJMCApiKey() {
- return this.driver.findElement(By.id("jmc-api-key")).getText();
- }
- public ProjectSettingsPage toggleJMCOnOff() {
- final boolean jmcEnabled = isJMCEnabled();
- final WebElement element = jmcEnabled ?
- driver.findElement(By.id("project-config-jmc-change-OFF")) :
- driver.findElement(By.id("project-config-jmc-change-ON"));
- element.click();
- driver.waitUntil(new Function<WebDriver, Boolean>() {
- public Boolean apply(@Nullable WebDriver from) {
- return isJMCEnabled() != jmcEnabled;
- }
- });
- return this;
- }
- public ProjectSettingsPage deactivateApiKey() {
- final WebElement checkbox = getApiKeyElement();
- if (checkbox.isSelected()) {
- checkbox.toggle();
- }
- return this;
- }
- public ProjectSettingsPage activateApiKey() {
- getApiKeyElement().setSelected();
- driver.waitUntil(new Function<WebDriver, Boolean>() {
- public Boolean apply(@Nullable WebDriver from) {
- return "false".equals(driver.findElement(By.id("jmc-apikey-beingreset")).getValue());
- }
- });
- return this;
- }
- private WebElement getApiKeyElement() {
- return driver.findElement(By.id("jmc-apikey-active"));
- }
- }