Example usage for org.openqa.selenium OutputType convertFromPngBytes

List of usage examples for org.openqa.selenium OutputType convertFromPngBytes

Introduction

In this page you can find the example usage for org.openqa.selenium OutputType convertFromPngBytes.

Prototype

T convertFromPngBytes(byte[] png);

Source Link

Document

Convert the given png to a requested format.

Usage

From source file:com.machinepublishers.jbrowserdriver.Element.java

License:Apache License

/**
 * {@inheritDoc}/*from  w w w .  java2  s .c  om*/
 */
@Override
public <X> X getScreenshotAs(OutputType<X> outputType) throws WebDriverException {
    try {
        byte[] bytes = null;
        synchronized (lock.validated()) {
            bytes = remote.getScreenshot();
        }
        if (bytes == null) {
            return null;
        }
        return outputType.convertFromPngBytes(bytes);
    } catch (Throwable t) {
        Util.handleException(t);
        return null;
    }
}

From source file:com.machinepublishers.jbrowserdriver.JBrowserDriver.java

License:Apache License

@Override
public <X> X getScreenshotAs(final OutputType<X> outputType) throws WebDriverException {
    try {/*from www .  ja va 2s  .c  o  m*/
        byte[] bytes;
        synchronized (lock.validated()) {
            bytes = remote.getScreenshot();
        }
        if (bytes == null) {
            return null;
        }
        return outputType.convertFromPngBytes(bytes);
    } catch (Throwable t) {
        Util.handleException(t);
        return null;
    }
}

From source file:com.machinepublishers.jbrowserdriver.JBrowserDriverServer.java

License:Apache License

/**
 * {@inheritDoc}//from w  ww.j  a v a  2 s. com
 */
@Override
public <X> X getScreenshotAs(final OutputType<X> outputType) throws WebDriverException {
    return outputType.convertFromPngBytes(getScreenshot());
}

From source file:com.opera.core.systems.OperaDriver.java

License:Apache License

public <X> X getScreenshotAs(OutputType<X> target) throws WebDriverException {
    OperaWebElement body = (OperaWebElement) findElementByTagName("body");
    return target.convertFromPngBytes(body.saveScreenshot(0).getPng());
}