View Javadoc
1   package com.atlassian.webdriver.refapp;
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.Header;
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.page.HomePage;
16  import com.atlassian.pageobjects.page.LoginPage;
17  import com.atlassian.pageobjects.page.WebSudoPage;
18  import com.atlassian.webdriver.AtlassianWebDriverModule;
19  import com.atlassian.webdriver.pageobjects.DefaultWebDriverTester;
20  import com.atlassian.webdriver.pageobjects.WebDriverTester;
21  import com.atlassian.webdriver.refapp.component.RefappHeader;
22  import com.atlassian.webdriver.refapp.page.RefappAdminHomePage;
23  import com.atlassian.webdriver.refapp.page.RefappHomePage;
24  import com.atlassian.webdriver.refapp.page.RefappLoginPage;
25  import com.atlassian.webdriver.refapp.page.RefappWebSudoPage;
26  
27  import static com.google.common.base.Preconditions.checkNotNull;
28  
29  /**
30   *
31   */
32  @Defaults(instanceId = "refapp", contextPath = "/refapp", httpPort = 5990)
33  public class RefappTestedProduct implements TestedProduct<WebDriverTester> {
34      private final PageBinder pageBinder;
35      private final WebDriverTester webDriverTester;
36      private final ProductInstance productInstance;
37  
38      public RefappTestedProduct(TestedProductFactory.TesterFactory<WebDriverTester> testerFactory, ProductInstance productInstance) {
39          checkNotNull(productInstance);
40          WebDriverTester tester = null;
41          if (testerFactory == null) {
42              tester = new DefaultWebDriverTester();
43          } else {
44              tester = testerFactory.create();
45          }
46          this.webDriverTester = tester;
47          this.productInstance = productInstance;
48          this.pageBinder = new InjectPageBinder(productInstance, tester, new StandardModule(this),
49                  new AtlassianWebDriverModule(this), new ElementModule(), new TimeoutsModule());
50  
51          this.pageBinder.override(Header.class, RefappHeader.class);
52          this.pageBinder.override(HomePage.class, RefappHomePage.class);
53          this.pageBinder.override(AdminHomePage.class, RefappAdminHomePage.class);
54          this.pageBinder.override(LoginPage.class, RefappLoginPage.class);
55          this.pageBinder.override(WebSudoPage.class, RefappWebSudoPage.class);
56      }
57  
58      public RefappHomePage gotoHomePage() {
59          return pageBinder.navigateToAndBind(RefappHomePage.class);
60      }
61  
62      public RefappAdminHomePage gotoAdminHomePage() {
63          return pageBinder.navigateToAndBind(RefappAdminHomePage.class);
64      }
65  
66      public RefappLoginPage gotoLoginPage() {
67          return pageBinder.navigateToAndBind(RefappLoginPage.class);
68      }
69  
70      public <P extends Page> P visit(Class<P> pageClass, Object... args) {
71          return pageBinder.navigateToAndBind(pageClass, args);
72      }
73  
74      public PageBinder getPageBinder() {
75          return pageBinder;
76      }
77  
78      public ProductInstance getProductInstance() {
79          return productInstance;
80      }
81  
82      public WebDriverTester getTester() {
83          return webDriverTester;
84      }
85  }