Java Code Examples for org.openqa.selenium.phantomjs.PhantomJSDriver#getScreenshotAs()

The following examples show how to use org.openqa.selenium.phantomjs.PhantomJSDriver#getScreenshotAs() . 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: HtmlExporter2BYTES.java    From yuzhouwan with Apache License 2.0 5 votes vote down vote up
/**
 * 将带有 chart、map 等动态图表的 html 转换为 图片(可以额外配置 cookie 的权限控制).
 *
 * @param url         目标 URL
 * @param addedCookie 添加 cookie
 * @return 图片 byte 数组
 */
@Override
public byte[] convert2Image(String url, Cookie addedCookie, Integer width, Integer height) {
    PhantomJSDriver driver = null;
    try {
        driver = HtmlExporterUtils.prepare(url, addedCookie, width, height);
        return driver.getScreenshotAs(OutputType.BYTES);
    } finally {
        HtmlExporterUtils.release(driver);
    }
}
 
Example 2
Source File: HtmlExporter2BASE64.java    From yuzhouwan with Apache License 2.0 5 votes vote down vote up
/**
 * 将带有 chart、map 等动态图表的 html 转换为 图片(可以额外配置 cookie 的权限控制).
 *
 * @param url         目标 URL
 * @param addedCookie 添加 cookie
 * @return 图片 string 字符串
 */
@Override
public String convert2Image(String url, Cookie addedCookie, Integer width, Integer height) {
    PhantomJSDriver driver = null;
    try {
        driver = HtmlExporterUtils.prepare(url, addedCookie, width, height);
        return driver.getScreenshotAs(OutputType.BASE64);
    } finally {
        HtmlExporterUtils.release(driver);
    }
}
 
Example 3
Source File: HtmlExporter2File.java    From yuzhouwan with Apache License 2.0 5 votes vote down vote up
/**
 * 将带有 chart、map 等动态图表的 html 转换为 图片(可以额外配置 cookie 的权限控制).
 *
 * @param url         目标 URL
 * @param addedCookie 添加 cookie
 * @return 图片文件
 */
@Override
public File convert2Image(String url, Cookie addedCookie, Integer width, Integer height) {
    PhantomJSDriver driver = null;
    try {
        driver = HtmlExporterUtils.prepare(url, addedCookie, width, height);
        return driver.getScreenshotAs(OutputType.FILE);
    } finally {
        HtmlExporterUtils.release(driver);
    }
}