Example usage for org.openqa.selenium.remote Augmenter Augmenter

List of usage examples for org.openqa.selenium.remote Augmenter Augmenter

Introduction

In this page you can find the example usage for org.openqa.selenium.remote Augmenter Augmenter.

Prototype

Augmenter

Source Link

Usage

From source file:at.tugraz.ist.cucumber.SeleniumStepdefs.java

License:Open Source License

private void captureScreen() {
    if (this.driver != null) {
        WebDriver augmenter = new Augmenter().augment(driver);
        byte[] imageBytes = ((TakesScreenshot) augmenter).getScreenshotAs(OutputType.BYTES);
        this.scenario.write("");
        this.scenario.embed(imageBytes, "image/png");
    }/*from w ww  .  j  a va  2s.co  m*/
}

From source file:ca.nrc.cadc.web.selenium.AbstractWebApplicationIntegrationTest.java

License:Open Source License

protected void captureScreenShot(final String outputFileName) throws IOException {
    final String filename = outputFileName + ".png";
    final WebDriver augmentedDriver = new Augmenter().augment(driver);
    final File sourceFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);

    FileUtils.copyFile(sourceFile, new File("./" + filename));

    System.err.println(String.format("Saved screenshot as '%s'", filename));
}

From source file:com.autocognite.appium.lib.base.AbstractAppiumUiDriver.java

License:Apache License

public TakesScreenshot getScreenshotAugmentedDriver() {
    return (TakesScreenshot) (new Augmenter().augment(getDriver()));
}

From source file:com.coderoad.automation.rocketTruedx.RocketTruedxNaBasePage.java

License:Open Source License

/**
 * Takepic./*from   www  . j  av a2  s . c  o  m*/
 * 
 * @param make the make
 */
public void takepic(String make) {

    String browser = getBrowserName(getDriver());
    WebDriver augmentedDriver = new Augmenter().augment(getDriver());

    File scrFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);

    DateFormat dateFormat = new SimpleDateFormat("dd_MMM_yyyy__hh_mm_ssaa");

    String destDir = "testresult/" + make;
    new File(destDir).mkdirs();
    /*
     * if(browser.contentEquals("Firefox")) browser="Firefox_"; else
     * if(browser.contentEquals("Internet Explorer"))
     * browser="InternetExplorer_";
     */
    String destFile = browser + "_" + dateFormat.format(new Date()) + ".png";

    try {
        FileUtils.copyFile(scrFile, new File(destDir + "/" + destFile));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.ecofactor.qa.automation.util.PageUtil.java

License:Open Source License

/**
 * Mobile save screenshot.//from w w  w . j  a  v  a  2  s  .c o  m
 * @param name the name
 * @param driver the driver
 */
public static void mobileSaveScreenshot(String name, WebDriver driver) {

    try {

        WebDriver augmentedDriver = new Augmenter().augment(driver);
        File screenshot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(screenshot, new File("target\\screenshots\\" + name + ".png"));

        File screenShotFile = new File("target\\screenshots\\" + name + ".png");
        if (screenShotFile.exists()) {
            logger.info("Saved screenshot for " + name + " at " + screenShotFile.getAbsolutePath());
        } else {
            logger.info("Unable to save screenshot for " + name + " at " + screenShotFile.getAbsolutePath());
        }
    } catch (Exception e) {
        logger.error("Error taking screenshot for " + name, e);
    }
}

From source file:com.epam.gepard.selenium.browsers.WebDriverUtil.java

License:Open Source License

/**
 * Write an event message to the log.//  w w  w  .  ja  v  a2s  .com
 *
 * @param text     Event message
 * @param makeDump if true, page source dump will be created.
 */
public void logEvent(final String text, final boolean makeDump) {
    String addStr = "";
    if (!text.startsWith("<font")) {
        tc.getTestClassExecutionData().addSysOut(text);
    }
    if (tc.getTestClassExecutionData().getHtmlRunReporter().getTestMethodHtmlLog() != null) {
        if (makeDump) {
            try {
                String dumpFileName = dumpSource(true);
                File dumpFile = new File(dumpFileName);
                String screenshotFileName = dumpFileName + ".png";
                if (selenium != null) {
                    selenium.windowMaximize();
                    WebDriver augmentedDriver = new Augmenter().augment(webDriver);
                    File screenShot = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
                    FileUtil fileUtil = new FileUtil();
                    File screenShotFile = new File(screenshotFileName);
                    fileUtil.copy(screenShot, screenShotFile);
                }
                String dumpFileName2 = dumpSource(false);
                File dumpFile2 = new File(dumpFileName2);
                addStr = " <small>[<a href=\"" + dumpFile.getName() + "\" target=\"_new\">source</a>]"
                        + " [<a href=\"" + dumpFile2.getName() + "\" target=\"_new\">view</a>]" + " [<a href=\""
                        + dumpFile.getName() + ".png\" target=\"_new\">screenshot</a>]</small>";
            } catch (Exception e) {
                addStr = " <small>[Dump failed]</small>";
            }
        }
        tc.getTestClassExecutionData().getHtmlRunReporter().getTestMethodHtmlLog()
                .insertText("<tr><td>&nbsp;</td><td bgcolor=\"#F0F0F0\">" + text + addStr + "</td></tr>\n");
    }
}

From source file:com.fmb.common.LogTools.java

License:Apache License

public static String screenShot(BrowserEmulator be) {
    //      String dir = "screenshot"; // TODO
    String dir = "target/publish-report"; //?screenshot
    String time = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date());
    String screenShotPath = dir + File.separator + time + ".png";

    WebDriver augmentedDriver = null;//from  ww w  . j  a v a  2 s .  com
    if (GlobalSettings.browserCoreType == 1 || GlobalSettings.browserCoreType == 3) {
        augmentedDriver = be.getBrowserCore();
        augmentedDriver.manage().window().setPosition(new Point(0, 0));
        augmentedDriver.manage().window().setSize(new Dimension(9999, 9999));
    } else if (GlobalSettings.browserCoreType == 2) {
        augmentedDriver = new Augmenter().augment(be.getBrowserCore());
    } else {
        return "Incorrect browser type";
    }

    try {
        File sourceFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE);
        FileUtils.copyFile(sourceFile, new File(screenShotPath));
    } catch (Exception e) {
        e.printStackTrace();
        return "Failed to screenshot";
    }

    // Convert '\' into '/' for web image browsing.
    return screenShotPath.replace("\\", "/");
}

From source file:com.galenframework.browser.SeleniumGridBrowserFactory.java

License:Apache License

@Override
public Browser openBrowser() {
    DesiredCapabilities desiredCapabilities = new DesiredCapabilities();

    if (platform != null) {
        desiredCapabilities.setPlatform(platform);
    }/*  w w  w  . ja v  a  2 s  .co m*/

    if (browser != null) {
        desiredCapabilities.setBrowserName(browser);
    }

    if (browserVersion != null) {
        desiredCapabilities.setVersion(browserVersion);
    }

    for (Map.Entry<String, String> dc : this.desiredCapabilities.entrySet()) {
        desiredCapabilities.setCapability(dc.getKey(), dc.getValue());
    }

    try {

        WebDriver driver = new RemoteWebDriver(new URL(gridUrl), desiredCapabilities);
        WebDriver augmentedDriver = new Augmenter().augment(driver);
        return new SeleniumBrowser(augmentedDriver);
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}

From source file:com.google.testing.web.Browser.java

License:Apache License

/**
 * Provisions and returns a new {@link WebDriver} session.
 *
 * @param capabilities Configuration of the browser.
 *//*from  ww  w. ja va  2s  . c o m*/
public WebDriver newSession(Capabilities capabilities) {
    DesiredCapabilities desired = new DesiredCapabilities(capabilities);
    WebDriver driver = new Augmenter().augment(new RemoteWebDriver(constructUrl(address), desired));

    return driver;
}

From source file:com.google.testing.web.WebTest.java

License:Apache License

/**
 * Provisions and returns a new {@link WebDriver} session.
 *
 * @param capabilities Configuration of the browser.
 *///from  ww w. j  a va  2 s. c  o  m
public WebDriver newWebDriverSession(Capabilities capabilities) {
    WebDriver driver = new Augmenter().augment(new RemoteWebDriver(wd, capabilities));

    return driver;
}