View Javadoc

1   package com.atlassian.webdriver.it.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.webdriver.AtlassianWebDriverModule;
14  import com.atlassian.webdriver.pageobjects.DefaultWebDriverTester;
15  import com.atlassian.webdriver.pageobjects.WebDriverTester;
16  import org.slf4j.LoggerFactory;
17  
18  import static com.google.common.base.Preconditions.checkNotNull;
19  
20  @Defaults(instanceId = "testapp", contextPath = "/", httpPort = 5990)
21  public class SimpleTestedProduct implements TestedProduct<WebDriverTester>
22  {
23      private final PageBinder pageBinder;
24      private final WebDriverTester  webDriverTester;
25      private final ProductInstance productInstance;
26  
27      public SimpleTestedProduct(TestedProductFactory.TesterFactory<WebDriverTester> testerFactory, ProductInstance productInstance)
28      {
29          this.productInstance = checkNotNull(productInstance);
30  
31          this.webDriverTester =  new DefaultWebDriverTester();
32          this.pageBinder = new InjectPageBinder(productInstance, webDriverTester, new StandardModule(this),
33                  new AtlassianWebDriverModule(this), new BrowserModule(),
34                  new LoggerModule(LoggerFactory.getLogger(SimpleTestedProduct.class)));
35      }
36  
37      public <P extends Page> P visit(Class<P> pageClass, Object... args)
38      {
39          return pageBinder.navigateToAndBind(pageClass, args);
40      }
41  
42      public PageBinder getPageBinder()
43      {
44          return pageBinder;
45      }
46  
47      public ProductInstance getProductInstance()
48      {
49          return productInstance;
50      }
51  
52      public WebDriverTester getTester()
53      {
54          return webDriverTester;
55      }
56  }