View Javadoc

1   package com.atlassian.webdriver.confluence;
2   
3   import com.atlassian.pageobjects.Defaults;
4   import com.atlassian.pageobjects.Page;
5   import com.atlassian.pageobjects.PageBinder;
6   import com.atlassian.pageobjects.ProductInstance;
7   import com.atlassian.pageobjects.TestedProduct;
8   import com.atlassian.pageobjects.TestedProductFactory;
9   import com.atlassian.pageobjects.binder.InjectPageBinder;
10  import com.atlassian.pageobjects.binder.StandardModule;
11  import com.atlassian.pageobjects.component.WebSudoBanner;
12  import com.atlassian.pageobjects.elements.ElementModule;
13  import com.atlassian.pageobjects.elements.timeout.TimeoutsModule;
14  import com.atlassian.pageobjects.page.AdminHomePage;
15  import com.atlassian.pageobjects.component.Header;
16  import com.atlassian.pageobjects.page.HomePage;
17  import com.atlassian.pageobjects.page.LoginPage;
18  import com.atlassian.pageobjects.page.WebSudoPage;
19  import com.atlassian.webdriver.AtlassianWebDriverModule;
20  import com.atlassian.webdriver.confluence.component.header.ConfluenceHeader;
21  import com.atlassian.webdriver.confluence.component.header.ConfluenceWebSudoBanner;
22  import com.atlassian.webdriver.confluence.page.ConfluenceAdminHomePage;
23  import com.atlassian.webdriver.confluence.page.ConfluenceLoginPage;
24  import com.atlassian.webdriver.confluence.page.ConfluenceWebSudoPage;
25  import com.atlassian.webdriver.confluence.page.DashboardPage;
26  import com.atlassian.webdriver.pageobjects.DefaultWebDriverTester;
27  import com.atlassian.webdriver.pageobjects.WebDriverTester;
28  import org.openqa.selenium.support.FindBy;
29  
30  import static com.google.common.base.Preconditions.checkNotNull;
31  
32  /**
33   *
34   */
35  @Defaults(instanceId = "confluence", contextPath = "/confluence", httpPort = 1990)
36  public class ConfluenceTestedProduct implements TestedProduct<WebDriverTester>
37  {
38      private String loggedInUsername;
39      private String loggedInPassword;
40  
41      private final PageBinder pageBinder;
42      private final WebDriverTester webDriverTester;
43      private final ProductInstance productInstance;
44  
45      public ConfluenceTestedProduct(TestedProductFactory.TesterFactory<WebDriverTester> testerFactory, ProductInstance productInstance)
46      {
47          checkNotNull(productInstance);
48          WebDriverTester tester = null;
49          if (testerFactory == null)
50          {
51              tester = new DefaultWebDriverTester();
52          }
53          else
54          {
55              tester = testerFactory.create();
56          }
57          this.webDriverTester = tester;
58          this.productInstance = productInstance;
59          this.pageBinder = new InjectPageBinder(productInstance, tester,
60              new StandardModule(this), new AtlassianWebDriverModule(this), new ElementModule(), new TimeoutsModule());
61  
62          this.pageBinder.override(Header.class, ConfluenceHeader.class);
63          this.pageBinder.override(HomePage.class, DashboardPage.class);
64          this.pageBinder.override(LoginPage.class, ConfluenceLoginPage.class);
65          this.pageBinder.override(AdminHomePage.class, ConfluenceAdminHomePage.class);
66          this.pageBinder.override(WebSudoPage.class, ConfluenceWebSudoPage.class);
67          this.pageBinder.override(WebSudoBanner.class, ConfluenceWebSudoBanner.class);
68      }
69  
70      public DashboardPage gotoHomePage()
71      {
72          return pageBinder.navigateToAndBind(DashboardPage.class);
73      }
74  
75      public ConfluenceAdminHomePage gotoAdminHomePage()
76      {
77          return pageBinder.navigateToAndBind(ConfluenceAdminHomePage.class);
78      }
79  
80      public ConfluenceLoginPage gotoLoginPage()
81      {
82          return pageBinder.navigateToAndBind(ConfluenceLoginPage.class);
83      }
84  
85      public <P extends Page> P visit(Class<P> pageClass, Object... args)
86      {
87          return pageBinder.navigateToAndBind(pageClass, args);
88      }
89  
90      public PageBinder getPageBinder()
91      {
92          return pageBinder;
93      }
94  
95      public ProductInstance getProductInstance()
96      {
97          return productInstance;
98      }
99  
100     public WebDriverTester getTester()
101     {
102         return webDriverTester;
103     }
104 
105     public String getLoggedInUsername() {
106         return loggedInUsername;
107     }
108 
109     public String getLoggedInPassword() {
110         return loggedInPassword;
111     }
112 
113     public void setLoggedInUser(String loggedInUsername, String password) {
114         this.loggedInUsername = loggedInUsername;
115         this.loggedInPassword = password;
116     }
117 }