PageRenderTime 50ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/src/test/java/it/page/ProjectSettingsPage.java

https://bitbucket.org/atlassian/jiraconnect-jiraplugin/
Java | 80 lines | 64 code | 14 blank | 2 comment | 2 complexity | 81d827e44a85b24b1b5c970ef5302728 MD5 | raw file
  1. package it.page;
  2. import com.atlassian.jira.pageobjects.pages.AbstractJiraPage;
  3. import com.atlassian.pageobjects.elements.ElementBy;
  4. import com.atlassian.pageobjects.elements.PageElement;
  5. import com.atlassian.pageobjects.elements.query.TimedCondition;
  6. import com.google.common.base.Function;
  7. import org.openqa.selenium.By;
  8. import org.openqa.selenium.WebDriver;
  9. import org.openqa.selenium.WebElement;
  10. import javax.annotation.Nullable;
  11. /**
  12. */
  13. public class ProjectSettingsPage extends AbstractJiraPage {
  14. private final static String URI = "/plugins/servlet/project-config/%s/summary";
  15. private final String projectKey;
  16. @ElementBy(id = "summary-settings_heading")
  17. private PageElement projectSettings;
  18. public ProjectSettingsPage(String projectKey) {
  19. this.projectKey = projectKey;
  20. }
  21. @Override
  22. public TimedCondition isAt() {
  23. return projectSettings.timed().isPresent();
  24. }
  25. public String getUrl() {
  26. return String.format(URI, projectKey);
  27. }
  28. public boolean isJMCEnabled() {
  29. return this.driver.elementIsVisible(By.id("project-config-jmc-change-IS-ON"));
  30. }
  31. public String getJMCApiKey() {
  32. return this.driver.findElement(By.id("jmc-api-key")).getText();
  33. }
  34. public ProjectSettingsPage toggleJMCOnOff() {
  35. final boolean jmcEnabled = isJMCEnabled();
  36. final WebElement element = jmcEnabled ?
  37. driver.findElement(By.id("project-config-jmc-change-OFF")) :
  38. driver.findElement(By.id("project-config-jmc-change-ON"));
  39. element.click();
  40. driver.waitUntil(new Function<WebDriver, Boolean>() {
  41. public Boolean apply(@Nullable WebDriver from) {
  42. return isJMCEnabled() != jmcEnabled;
  43. }
  44. });
  45. return this;
  46. }
  47. public ProjectSettingsPage deactivateApiKey() {
  48. final WebElement checkbox = getApiKeyElement();
  49. if (checkbox.isSelected()) {
  50. checkbox.toggle();
  51. }
  52. return this;
  53. }
  54. public ProjectSettingsPage activateApiKey() {
  55. getApiKeyElement().setSelected();
  56. driver.waitUntil(new Function<WebDriver, Boolean>() {
  57. public Boolean apply(@Nullable WebDriver from) {
  58. return "false".equals(driver.findElement(By.id("jmc-apikey-beingreset")).getValue());
  59. }
  60. });
  61. return this;
  62. }
  63. private WebElement getApiKeyElement() {
  64. return driver.findElement(By.id("jmc-apikey-active"));
  65. }
  66. }