View Javadoc

1   package com.atlassian.pageobjects.elements.test.pageobjects;
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.BrowserModule;
10  import com.atlassian.pageobjects.binder.InjectPageBinder;
11  import com.atlassian.pageobjects.binder.LoggerModule;
12  import com.atlassian.pageobjects.binder.StandardModule;
13  import com.atlassian.pageobjects.elements.ElementModule;
14  import com.atlassian.pageobjects.elements.PageElement;
15  import com.atlassian.pageobjects.elements.WebDriverElement;
16  import com.atlassian.pageobjects.elements.timeout.Timeouts;
17  import com.atlassian.pageobjects.elements.timeout.TimeoutsModule;
18  import com.atlassian.webdriver.AtlassianWebDriverModule;
19  import com.atlassian.webdriver.pageobjects.DefaultWebDriverTester;
20  import com.atlassian.webdriver.pageobjects.WebDriverTester;
21  import org.openqa.selenium.By;
22  
23  import static com.google.common.base.Preconditions.checkNotNull;
24  
25  @Defaults(instanceId = "testapp", contextPath = "/", httpPort = 5990)
26  public class PageElementsTestedProduct implements TestedProduct<WebDriverTester>
27  {
28      private final PageBinder pageBinder;
29      private final WebDriverTester  webDriverTester;
30      private final ProductInstance productInstance;
31      private final Timeouts timeouts;
32  
33      public PageElementsTestedProduct(TestedProductFactory.TesterFactory<WebDriverTester> testerFactory, ProductInstance productInstance)
34      {
35          checkNotNull(productInstance);
36          this.productInstance = productInstance;
37          this.webDriverTester =  new DefaultWebDriverTester();
38          TimeoutsModule timeoutsModule =  new TimeoutsModule();
39          this.timeouts = timeoutsModule.timeouts();
40          this.pageBinder = new InjectPageBinder(productInstance, webDriverTester,
41                  new StandardModule(this),
42                  new AtlassianWebDriverModule(this),
43                  new ElementModule(),
44                  new TimeoutsModule(),
45                  new BrowserModule(),
46                  new LoggerModule(PageElementsTestedProduct.class));
47      }
48  
49      public Timeouts timeouts()
50      {
51          return timeouts;
52      }
53  
54      public PageElement find(final By by)
55      {
56          return getPageBinder().bind(WebDriverElement.class, by);
57      }
58  
59      public <P extends Page> P visit(Class<P> pageClass, Object... args)
60      {
61          return pageBinder.navigateToAndBind(pageClass, args);
62      }
63  
64      public PageBinder getPageBinder()
65      {
66          return pageBinder;
67      }
68  
69      public ProductInstance getProductInstance()
70      {
71          return productInstance;
72      }
73  
74      public WebDriverTester getTester()
75      {
76          return webDriverTester;
77      }
78  }