Java Code Examples for org.testng.Reporter#setCurrentTestResult()
The following examples show how to use
org.testng.Reporter#setCurrentTestResult() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScreenshotListener.java From selenium with Apache License 2.0 | 6 votes |
@Override public void onTestFailure(ITestResult result) { Reporter.setCurrentTestResult(result); try { outputDirectory.mkdirs(); File outFile = File.createTempFile("TEST-" + result.getName(), ".png", outputDirectory); outFile.delete(); selenium.captureScreenshot(outFile.getAbsolutePath()); Reporter.log("<a href='" + outFile.getName() + "'>screenshot</a>"); } catch (Exception e) { e.printStackTrace(); Reporter.log("Couldn't create screenshot"); Reporter.log(e.getMessage()); } Reporter.setCurrentTestResult(null); }
Example 2
Source File: DriverListener.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * Perform post-invocation processing: * <ul> * <li>If indicated, close the driver that was acquired for this method.</li> * </ul> * * @param invokedMethod an object representing the method that's just been invoked * @param testResult test result object for the method that's just been invoked */ @Override public void afterInvocation(final IInvokedMethod invokedMethod, final ITestResult testResult) { // ensure current test result is set Reporter.setCurrentTestResult(testResult); Object obj = testResult.getInstance(); Method method = invokedMethod.getTestMethod().getConstructorOrMethod().getMethod(); DriverManager.afterInvocation(obj, method); }
Example 3
Source File: PageSourceArtifact.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public boolean canGetArtifact(final ITestResult result) { // ensure current test result is set Reporter.setCurrentTestResult(result); Optional<WebDriver> optDriver = DriverManager.nabDriver(result.getInstance()); return PageSourceUtils.canGetArtifact(optDriver, LOGGER); }
Example 4
Source File: PageSourceArtifact.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public byte[] getArtifact(final ITestResult result) { // ensure current test result is set Reporter.setCurrentTestResult(result); Optional<WebDriver> optDriver = DriverManager.nabDriver(result.getInstance()); return PageSourceUtils.getArtifact(optDriver, result.getThrowable(), LOGGER).getBytes(); }
Example 5
Source File: ScreenshotArtifact.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public boolean canGetArtifact(final ITestResult result) { // ensure current test result is set Reporter.setCurrentTestResult(result); Optional<WebDriver> optDriver = DriverManager.nabDriver(result.getInstance()); return ScreenshotUtils.canGetArtifact(optDriver, LOGGER); }
Example 6
Source File: ScreenshotArtifact.java From Selenium-Foundation with Apache License 2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public byte[] getArtifact(final ITestResult result) { // ensure current test result is set Reporter.setCurrentTestResult(result); Optional<WebDriver> optDriver = DriverManager.nabDriver(result.getInstance()); return ScreenshotUtils.getArtifact(optDriver, result.getThrowable(), LOGGER); }
Example 7
Source File: TestngRetry.java From WebAndAppUITesting with GNU General Public License v3.0 | 5 votes |
@Override public boolean retry(ITestResult result) { if (retryCount <= maxRetryCount) { String message = "Retry for [" + result.getName() + "] on class [" + result.getTestClass().getName() + "] Retry " + retryCount + " times"; logger.info(message); Reporter.setCurrentTestResult(result); Reporter.log("RunCount=" + (retryCount + 1)); retryCount++; return true; } return false; }
Example 8
Source File: DriverListener.java From Selenium-Foundation with Apache License 2.0 | 3 votes |
/** * Perform pre-invocation processing: * <ul> * <li>Ensure that a driver instance has been created for the test.</li> * <li>Store the driver instance for subsequent dispensing.</li> * <li>Manage configured driver timeout intervals.</li> * <li>If specified, open the initial page, storing the page object for subsequent dispensing.</li> * </ul> * * @param invokedMethod an object representing the method that's about to be invoked * @param testResult test result object for the method that's about to be invoked */ @Override public void beforeInvocation(final IInvokedMethod invokedMethod, final ITestResult testResult) { // ensure current test result is set Reporter.setCurrentTestResult(testResult); Object obj = testResult.getInstance(); Method method = invokedMethod.getTestMethod().getConstructorOrMethod().getMethod(); DriverManager.beforeInvocation(obj, method); }
Example 9
Source File: HtmlReportService.java From qaf with MIT License | 2 votes |
public void attachScreenShotLink(ITestResult tr, String file) { Reporter.setCurrentTestResult(tr); Reporter.log("<a href=\"" + file + "\" target=\"_blank\">View Screenshot</a><br>"); }