View Javadoc

1   package com.atlassian.webdriver.jira.page;
2   
3   import com.atlassian.pageobjects.Page;
4   import com.atlassian.pageobjects.binder.Init;
5   import com.atlassian.webdriver.jira.component.project.ProjectSummary;
6   import org.openqa.selenium.By;
7   import org.openqa.selenium.WebElement;
8   import org.openqa.selenium.support.FindBy;
9   
10  import java.util.ArrayList;
11  import java.util.Collections;
12  import java.util.List;
13  
14  /**
15   * TODO: Document this class / interface here
16   *
17   */
18  public class ProjectsViewPage extends JiraAdminAbstractPage
19  {
20  
21      @FindBy (id = "add_project")
22      private WebElement addProjectLink;
23  
24      private final List<ProjectSummary> projects;
25      
26      private final static String URI = "/secure/project/ViewProjects.jspa";
27  
28      public ProjectsViewPage()
29      {
30          projects = new ArrayList<ProjectSummary>();
31      }
32  
33      public String getUrl()
34      {
35          return URI;
36      }
37  
38      @Init
39      public void loadProjects()
40      {
41  
42          List<WebElement> rows = driver.findElements(By.cssSelector("table.grid > tbody > tr"));
43  
44          // Remove the th.
45          rows.remove(0);
46  
47          if (rows.get(0).getText().equals("You do not have the permissions to administer any projects, or there are none created."))
48          {
49              return;
50          }
51  
52          for(WebElement row : rows)
53          {
54              projects.add(pageBinder.bind(ProjectSummary.class, row));
55          }
56  
57      }
58  
59      public Page addProject()
60      {
61          throw new UnsupportedOperationException("addProject for ProjectViewPage has not been implemented");
62      }
63  
64      public List<ProjectSummary> getProjects()
65      {
66          return Collections.unmodifiableList(projects);
67      }
68  }