/** * Convenience method delegating to {@link GaleniumReportUtil#getLogger()}. * @return current logger */ public Logger getLogger() { return GaleniumReportUtil.getLogger(); }
/** * @param status status to use for final message * @param details final message */ public static void endExtentTest(ITestResult result, LogStatus status, String details) { getLogger().trace("GaleniumReportUtilendExtentTest(): getting extent test."); ExtentTest extentTest = getExtentTest(result); getLogger().trace("GaleniumReportUtilendExtentTest(): logging details."); extentTest.log(status, details); getLogger().trace("GaleniumReportUtilendExtentTest(): assigning categories."); TestInfoUtil.assignCategories(extentTest, result); getLogger().trace("GaleniumReportUtilendExtentTest(): ending extent report test"); EXTENT_REPORTS.endTest(extentTest); getLogger().trace("GaleniumReportUtilendExtentTest(): done"); }
private static Logger getLogger() { return GaleniumReportUtil.getMarkedLogger(MARKER); }
private ExtentTest updateExtentTest(ITestResult result) { ExtentTest extentTest = GaleniumReportUtil.getExtentTest(); if (!GaleniumReportUtil.haveMatchingName(result, extentTest)) { return GaleniumReportUtil.getExtentTest(result); } return extentTest; }
@Override public void onFinish(ITestContext context) { getLogger().trace("Generating Galen reports."); GaleniumReportUtil.createGalenReports(); }
logMsg.append(GaleniumReportUtil.takeScreenshot(result, driver)); logMsg.append("URL: ").append(driver.getCurrentUrl()).append(System.lineSeparator()); GaleniumReportUtil.getLogger().debug(GaleniumReportUtil.MARKER_FAIL, "Full stacktrace", throwable); getLogger().error(logMsg.toString()); GaleniumReportUtil.getLogger().error(msg, ex); throw new GaleniumException(msg, ex); GaleniumReportUtil.endExtentTest(result, LogStatus.FAIL, logMsgHtml);
getLogger().warn("local storage profile is null."); return; getLogger().debug("applying local storage profile: '" + profileToApply.getProfileName() + "'"); WebDriver driver = GaleniumContext.getDriver(); if (driver == null) { getLogger().error("driver is null, when trying to apply profile: " + profileToApply.getProfileName()); return; getLogger().error("driver cannot handle local storage, when trying to apply profile: " + profileToApply.getProfileName()); return; String key = item.getKey(); String value = item.getValue(); if (getLogger().isDebugEnabled()) { StringBuilder addItemMessage = new StringBuilder(); addItemMessage.append("adding local storage item to driver: '"); addItemMessage.append(value); addItemMessage.append("'"); getLogger().debug(addItemMessage.toString()); getLogger().warn("could not set local storage item ('" + key + "') when applying profile '" + profileToApply.getProfileName() + "'", ex); assignCategory(CATEGORY_PREFIX_LOCAL_STORAGE_PROFILE + profileToApply.getProfileName());
private static LayoutReport checkLayout(String testName, PageSpec spec, TestDevice device, SectionFilter tags, ValidationListener validationListener, Browser browser, WebDriver driver) { if (getLogger().isDebugEnabled()) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append("checking layout with: ('name' : '"); stringBuilder.append(GaleniumContext.getDriver().getCurrentUrl()); stringBuilder.append("'"); getLogger().debug(stringBuilder.toString()); getLogger().error("IOException with layout checking", ex); throw new GalenLayoutException("IOException with layout checking", ex); GaleniumReportUtil.addGalenResult(test); getLogger().error(msg);
@Override public void beforeConfiguration(ITestResult tr) { GaleniumReportUtil.getExtentTest(tr); }
protected void takeScreenshot(ITestResult result) { WebDriver driver = WebDriverManager.getCurrentDriver(); if (driver != null) { GaleniumReportUtil.takeScreenshot(result, driver); } }
/** * Assigns categories to {@link ExtentTest}. * @param categories to add */ public static void assignCategories(String... categories) { for (String category : categories) { assignCategory(category); } }
/** * @param name test name to retrieve test * @return test report associated with result */ public static ExtentTest getExtentTest(String name) { ExtentTest currentReport = getExtentTest(); if (currentReport == null || currentReport.getTest() == null || currentReport.getTest().getName() == null || !currentReport.getTest().getName().equals(name)) { currentReport = EXTENT_REPORTS.getExtentTest(name); setExtentTest(currentReport); } return currentReport; }
@Override public void onFinish(ITestContext context) { getLogger().trace("Generating Galen reports."); GaleniumReportUtil.createGalenReports(); }
logMsg.append(GaleniumReportUtil.takeScreenshot(result, driver)); logMsg.append("URL: ").append(driver.getCurrentUrl()).append(System.lineSeparator()); getLogger().error(logMsg.toString()); GaleniumReportUtil.getLogger().error(msg, ex); throw new GaleniumException(msg, ex); GaleniumReportUtil.endExtentTest(result, LogStatus.FAIL, logMsgHtml);
protected void fetchItems(WebDriver driver) { for (F storageFetcher : getFetchers()) { getLogger().debug("fetching items for profile '" + getProfileName() + "': " + storageFetcher.getFetcherName()); assignCategory(getCategoryPrefixFetcher() + storageFetcher.getFetcherName()); handleFetcher(driver, storageFetcher); } }
private static LayoutReport checkLayout(String testName, PageSpec spec, TestDevice device, SectionFilter tags, ValidationListener validationListener, Browser browser, WebDriver driver) { LayoutReport layoutReport; try { layoutReport = Galen.checkLayout(browser, spec, tags, validationListener); } catch (IOException ex) { getLogger().error("IOException with layout checking", ex); throw new GalenLayoutException("IOException with layout checking", ex); } // Creating an object that will contain the information about the test GalenTestInfo test = GalenTestInfo.fromString("Layoutcheck " + testName + " " + device.getName()); // Adding layout report to the test report test.getReport().layout(layoutReport, "check layout on " + driver.getCurrentUrl() + " with device: " + device.toString()); GaleniumReportUtil.addGalenResult(test); if (layoutReport.errors() > 0) { String prettyStringResult; try { prettyStringResult = layoutReport.getValidationErrorResults().get(0).getSpec().getPlace().toPrettyString(); } catch (NullPointerException ex) { prettyStringResult = "____NPE____"; } String msg = "FAILED: Layoutcheck " + prettyStringResult + " with device " + device.toString(); getLogger().error(msg); } return layoutReport; }
@Override public void onTestStart(ITestResult result) { GaleniumReportUtil.getExtentTest(result); }
protected void takeScreenshot(ITestResult result) { WebDriver driver = WebDriverManager.getCurrentDriver(); if (driver != null) { GaleniumReportUtil.takeScreenshot(result, driver); } }
@Override public boolean retry(ITestResult result) { if (getCount(result).incrementAndGet() > MAX_RETRY_COUNT) { // don't retry if max count is exceeded String failureMessage = "Exceeded max count (" + getCount(result).get() + "): " + result.getTestName(); logResult(GaleniumReportUtil.MARKER_FAIL, result, failureMessage); assignCategory("RERUN_MAX"); return false; } String infoMessage = "Rerunning test (" + getCount(result).get() + "): " + result.getTestName(); logResult(GaleniumReportUtil.MARKER_SKIP, result, infoMessage); assignCategory("RERUN_" + getCount(result).get()); return true; }
@Override public void onBeforeSection(PageValidation pageValidation, PageSection pageSection) { getLogger().trace("BeforeSection(PageValidation pageValidation, PageSection pageSection)"); }