private static void log(String command, String description, boolean success, boolean ifLowLevel) { logsResults.add(success); String escapedDescription = escapeHtml(description); String className = success ? "success" : "error"; StringBuilder builder = new StringBuilder(); if (ifLowLevel) { builder.append( "<tr class=\"" + className + " lowLevelAction" + "\"><td>" + command + "</td><td>" + escapedDescription + "</td><td> <br/> </td></tr>"); } else { builder.append( "<tr class=\"" + className + "\"><td>" + command + "</td><td>" + escapedDescription + "</td><td> <br/> </td></tr>"); } CommonUtils.appendTextToFile(logPath, builder.toString()); logJSError(NewDriverProvider.getWebDriver()); }
@Override public void onTestFailure(ITestResult result) { driver = NewDriverProvider.getWebDriver(); if (driver == null) { driver = NewDriverProvider.getWebDriver(); } imageCounter += 1; if ("true".equals(Configuration.getLogEnabled())) { try { new Shooter().savePageScreenshot(screenPath + imageCounter, driver); CommonUtils.appendTextToFile(screenPath + imageCounter + ".html", getPageSource(driver)); } catch (Exception e) { log( "onException", "driver has no ability to catch screenshot or html source - driver may died", false); } String exception = escapeHtml( result.getThrowable().toString() + "\n" + ExceptionUtils.getStackTrace(result.getThrowable())); StringBuilder builder = new StringBuilder(); builder.append( "<tr class=\"error\"><td>error</td><td><pre>" + exception + "</pre></td><td> <br/><a href='screenshots/screenshot" + imageCounter + ".png'>Screenshot</a><br/><a href='screenshots/screenshot" + imageCounter + ".html'>HTML Source</a></td></tr>"); CommonUtils.appendTextToFile(logPath, builder.toString()); logJSError(driver); onTestSuccess(result); } }
// MT05 @RelatedIssue(issueID = "HG-730") @Test( groups = {"MercuryLightboxTest_005", "MercuryLightboxTests", "Mercury"}, enabled = false) public void MercuryLightboxTest_005_BackButtonCloseLightbox() { AndroidDriver mobileDriver = NewDriverProvider.getMobileDriver(); LightboxComponentObject lightbox = new LightboxComponentObject(driver); lightbox.openMercuryArticleByName(wikiURL, MercurySubpages.GALLERY); String oldUrl = driver.getCurrentUrl(); lightbox.clickGalleryImage(0); Assertion.assertTrue(lightbox.isLightboxOpened(), "Lightbox is closed"); mobileDriver.execute(DriverCommand.GO_BACK, null); boolean result = !lightbox.isLightboxOpened(); PageObjectLogging.log("Lightbox", "is closed", "is opened", result); result = oldUrl.equals(driver.getCurrentUrl()); PageObjectLogging.log("URL", "is the same", "is different", result); }