Search in sources :

Example 1 with ImageLinkInfo

use of com.seleniumtests.reporter.info.ImageLinkInfo in project seleniumRobot by bhecquet.

the class TestImageLinkInfo method testOtherFormatLink.

@Test(groups = { "ut" })
public void testOtherFormatLink() {
    String formatOther = new ImageLinkInfo("/imageCapture.png").encode("avi");
    Assert.assertEquals(formatOther, "Image");
}
Also used : ImageLinkInfo(com.seleniumtests.reporter.info.ImageLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 2 with ImageLinkInfo

use of com.seleniumtests.reporter.info.ImageLinkInfo in project seleniumRobot by bhecquet.

the class WebUIDriver method logFinalDriverState.

/**
 * Logs current state of the browser
 */
private void logFinalDriverState(ITestResult testResult) {
    if (driver != null) {
        try {
            // issue #414: capture the whole screen
            driver.switchTo().defaultContent();
            // force screenshotUtil to use the driver of this WebUiDriver, not the currently selected one
            for (ScreenShot screenshot : new ScreenshotUtil(driver).capture(SnapshotTarget.PAGE, ScreenShot.class, true, true)) {
                scenarioLogger.logScreenshot(screenshot, null, name, SnapshotCheckType.FALSE);
                // add the last screenshots to TestInfo so that there is a quicklink on reports
                Info lastStateInfo = TestNGResultUtils.getTestInfo(testResult).get(TestStepManager.LAST_STATE_NAME);
                if (lastStateInfo != null) {
                    ((MultipleInfo) lastStateInfo).addInfo(new ImageLinkInfo(TestNGResultUtils.getUniqueTestName(testResult) + "/" + screenshot.getImagePath()));
                }
            }
        } catch (Exception e) {
            scenarioLogger.log("Error while logging: " + e.getMessage());
        }
    }
    try {
        // stop HAR capture
        if (config.getBrowserMobProxy() != null) {
            Har har = config.getBrowserMobProxy().endHar();
            scenarioLogger.logNetworkCapture(har, name);
        }
    } catch (Exception e) {
        scenarioLogger.log("Error while logging: " + e.getMessage());
    } finally {
        config.setBrowserMobProxy(null);
    }
}
Also used : ImageLinkInfo(com.seleniumtests.reporter.info.ImageLinkInfo) ScreenShot(com.seleniumtests.driver.screenshots.ScreenShot) ScreenshotUtil(com.seleniumtests.driver.screenshots.ScreenshotUtil) Har(net.lightbody.bmp.core.har.Har) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) Info(com.seleniumtests.reporter.info.Info) BrowserInfo(com.seleniumtests.browserfactory.BrowserInfo) MultipleInfo(com.seleniumtests.reporter.info.MultipleInfo) ImageLinkInfo(com.seleniumtests.reporter.info.ImageLinkInfo) ScenarioException(com.seleniumtests.customexception.ScenarioException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) ConfigurationException(com.seleniumtests.customexception.ConfigurationException) IOException(java.io.IOException)

Example 3 with ImageLinkInfo

use of com.seleniumtests.reporter.info.ImageLinkInfo in project seleniumRobot by bhecquet.

the class TestImageLinkInfo method testNullFormatLink.

@Test(groups = { "ut" })
public void testNullFormatLink() {
    String formatNull = new ImageLinkInfo("/imageCapture.png").encode(null);
    Assert.assertEquals(formatNull, "Image");
}
Also used : ImageLinkInfo(com.seleniumtests.reporter.info.ImageLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Example 4 with ImageLinkInfo

use of com.seleniumtests.reporter.info.ImageLinkInfo in project seleniumRobot by bhecquet.

the class TestImageLinkInfo method testHtmlLink.

@Test(groups = { "ut" })
public void testHtmlLink() {
    String formatHtml = new ImageLinkInfo("/imageCapture.html").encode("html");
    Assert.assertEquals(formatHtml, "<a href=\"/imageCapture.html\"><i class=\"fas fa-file-image\" aria-hidden=\"true\"></i></a>");
}
Also used : ImageLinkInfo(com.seleniumtests.reporter.info.ImageLinkInfo) Test(org.testng.annotations.Test) GenericTest(com.seleniumtests.GenericTest)

Aggregations

ImageLinkInfo (com.seleniumtests.reporter.info.ImageLinkInfo)4 GenericTest (com.seleniumtests.GenericTest)3 Test (org.testng.annotations.Test)3 BrowserInfo (com.seleniumtests.browserfactory.BrowserInfo)1 ConfigurationException (com.seleniumtests.customexception.ConfigurationException)1 ScenarioException (com.seleniumtests.customexception.ScenarioException)1 ScreenShot (com.seleniumtests.driver.screenshots.ScreenShot)1 ScreenshotUtil (com.seleniumtests.driver.screenshots.ScreenshotUtil)1 Info (com.seleniumtests.reporter.info.Info)1 MultipleInfo (com.seleniumtests.reporter.info.MultipleInfo)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Har (net.lightbody.bmp.core.har.Har)1