public ProductInstance getProductInstance() { return product.getProductInstance(); }
@SuppressWarnings("unchecked") public void configure(Binder binder) { binder.bind(TestedProduct.class).toInstance(testedProduct); binder.bind((Class<TestedProduct>) testedProduct.getClass()).toInstance(testedProduct); binder.bind(Tester.class).toInstance(testedProduct.getTester()); binder.bind((Class<Tester>) testedProduct.getTester().getClass()).toInstance(testedProduct.getTester()); binder.bind(ProductInstance.class).toInstance(testedProduct.getProductInstance()); } }
public PageBinder getPageBinder() { return product.getPageBinder(); }
public WebDriverTester getTester() { return product.getTester(); }
public static EchoPage goToIfNeeded(@Nonnull TestedProduct<WebDriverTester> product) { checkNotNull(product, "product"); EchoPage page = product.getPageBinder().bind(EchoPage.class, false); if (isAt(page, product)) { return page; } else { return product.visit(EchoPage.class); } }
public <P extends Page> P visit(Class<P> pageClass, Object... args) { return product.visit(pageClass, args); }
@Override public AtlassianWebDriver get() { return product.getTester().getDriver(); } };
/** * Create a ConnectRunner for an add-on with a specified key * @param testedProduct the product to install the add-on into * @param key the key for the add-on */ public ConnectRunner(TestedProduct testedProduct, String key) { this(testedProduct.getProductInstance().getBaseUrl(), key); }
private static boolean isAt(EchoPage page, TestedProduct<WebDriverTester> product) { return product.getTester().getDriver().getCurrentUrl().startsWith(product.getProductInstance().getBaseUrl()) && page.isAt().now(); } }
public void configure(Binder binder) { binder.bind(AtlassianWebDriver.class).toInstance(testedProduct.getTester().getDriver()); binder.bind(WebDriver.class).toInstance(testedProduct.getTester().getDriver()); binder.bind(SearchContext.class).toInstance(testedProduct.getTester().getDriver()); binder.bind(PageFactoryPostInjectionProcessor.class); binder.bind(Waiter.class).to(WebDriverWaiter.class); } }
/** * Checks whether given product supports injection. That is whether the product itself, or the associated page * binder is instance of {@link com.atlassian.pageobjects.inject.InjectionContext}. * * @param product product to verify * @return <code>true</code> if <tt>product</tt> supports injection */ public static boolean supportsInjection(TestedProduct<?> product) { if (product == null) { return false; } return product instanceof InjectionContext || product.getPageBinder() instanceof InjectionContext; }
/** * Create a ConnectRunner for an add-on with a specified key * @param testedProduct the product to install the add-on into * @param key the key for the add-on */ public ConnectRunner(TestedProduct testedProduct, String key) { this(testedProduct.getProductInstance().getBaseUrl(), key); }
@Override public void configure(Binder binder) { final AtlassianWebDriver driver = testedProduct.getTester().getDriver(); binder.bind(JavascriptExecutor.class).toInstance(driver); binder.bind(AjaxTracing.class).to(AjaxTracingImpl.class).asEagerSingleton(); final Optional<Capabilities> capabilities = CapabilityUtils.getBrowserCapabilities(driver); if (capabilities.isPresent()) { binder.bind(Capabilities.class).toInstance(capabilities.get()); } binder.bind(ConfluenceFrameExecutor.class).to(ConfluenceFrameExecutorTemplate.Lenient.class); // default, lenient == ignores frame exceptions binder.bind(ConfluenceFrameExecutor.class).annotatedWith(Names.named("lenient")).to(ConfluenceFrameExecutorTemplate.Lenient.class); binder.bind(ConfluenceFrameExecutor.class).annotatedWith(Names.named("strict")).to(ConfluenceFrameExecutorTemplate.Strict.class); }
/** * Checks whether given product supports injection. That is whether the product itself, or the associated page * binder is instance of {@link com.atlassian.pageobjects.inject.ConfigurableInjectionContext}. * * @param product product to verify * @return <code>true</code> if <tt>product</tt> supports configurable injection */ public static boolean supportsConfigurableInjection(TestedProduct<?> product) { if (product == null) { return false; } return product instanceof ConfigurableInjectionContext || product.getPageBinder() instanceof ConfigurableInjectionContext; }
private LifecycleTestUtils(TestedProduct<WebDriverTester> product) { String baseUrl = product.getProductInstance().getBaseUrl(); this.product = product; this.addonControlClient = new AddonControlClient(baseUrl, "admin", "admin"); this.connectClient = new AtlassianConnectRestClient(baseUrl, "admin", "admin"); }
/** * Returns injection context associated with given <tt>product</tt>. * * @param product product to retrieve context from * @return associated injection context, either from the product, or its page binder * @throws IllegalArgumentException if the product is not providing injection (which can be verified by * calling {@link #supportsInjection(com.atlassian.pageobjects.TestedProduct)} */ public static InjectionContext asInjectionContext(TestedProduct<?> product) { if (product instanceof InjectionContext) { return (InjectionContext) product; } else if (product.getPageBinder() instanceof InjectionContext) { return (InjectionContext) product.getPageBinder(); } else { throw new IllegalArgumentException("Product <" + product + "> does not support injection"); } }
public HelpTipApiClient(TestedProduct product, TestUser user) { this.baseUrl = product.getProductInstance().getBaseUrl(); this.defaultUsername = user.getUsername(); this.defaultPassword = user.getPassword(); this.userRequestSender = new UserRequestSender(baseUrl); }
/** * Returns configurable injection context associated with given <tt>product</tt>. * * @param product product to retrieve context from * @return associated injection context, either from the product, or its page binder * @throws IllegalArgumentException if the product is not providing configurable injection (which can be verified by * calling {@link #supportsConfigurableInjection(com.atlassian.pageobjects.TestedProduct)}. */ public static ConfigurableInjectionContext asConfigurableInjectionContext(TestedProduct<?> product) { if (product instanceof ConfigurableInjectionContext) { return (ConfigurableInjectionContext) product; } else if (product.getPageBinder() instanceof InjectionContext) { return (ConfigurableInjectionContext) product.getPageBinder(); } else { throw new IllegalArgumentException("Product <" + product + "> does not support configurable injection"); } } }
public HelpTipApiClient(TestedProduct product, TestUser user) { this.baseUrl = product.getProductInstance().getBaseUrl(); this.defaultUsername = user.getUsername(); this.defaultPassword = user.getPassword(); this.userRequestSender = new UserRequestSender(baseUrl); }
public AcceptanceTestHelper(TestUser user, String descriptorUrl, TestedProduct product) { this.user = user; this.descriptorUrl = descriptorUrl; addonDescriptorParser = new AddonDescriptorParser(descriptorUrl); connectRestClient = new AtlassianConnectRestClient( product.getProductInstance().getBaseUrl(), user.getUsername(), user.getPassword()); }