protected void setup(AutomationMain mainFactory, ApplicationContext context) throws AutomationFrameworkException { if (this.context == null) { this.context = context; if (StringUtils.isNotBlank(this.baseUrl)) { Browser.getCurrentBrowser().get(baseUrl); } } }
/** * Initializes and returns page class instance * * @param page - page class * @throws PageObjectException */ protected <T extends AbstractPageObject> T initPage(T page) throws PageObjectException { // get locators Locale locale; try { locale = new Locale(AutomationMain.getConfigProperties().getContentLanguage()); } catch (AutomationFrameworkException e) { throw new PageObjectException("Main factory initialization exception.", e); } try { Browser browser = Browser.getCurrentBrowser(); LOG.info("Current URL: " + getCurrentUrl()); if (StringUtils.isNotBlank(page.getPageUrl()) && !browser.getCurrentUrl().contains(page.getPageUrl())) { LOG.error("Navigate to URL: " + page.getPageUrl()); throw new PageObjectException( "Page validation exception. Expected page URL is " + page.getPageUrl() + " URL in fact " + getCurrentUrl()); } page.setPageFactory(this); page.init(browser, locale); LOG.info(page.getClass().getName() + " page created."); } catch (Exception e) { throw new PageObjectException( "Unable initialize " + page.getClass().getName() + " page by URL: " + page.getPageUrl() + "\n" + e.getMessage(), e); } return page; }
/** * Returns current URL * * @throws AutomationFrameworkException */ public String getCurrentUrl() throws AutomationFrameworkException { return Browser.getCurrentBrowser().getCurrentUrl(); }