Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException When ScreenShot #193

Open
bokala123 opened this issue Apr 7, 2020 · 0 comments
Open

NullPointerException When ScreenShot #193

bokala123 opened this issue Apr 7, 2020 · 0 comments

Comments

@bokala123
Copy link

bokala123 commented Apr 7, 2020

When I use AShot to Shot Screen,error is exit.
My source:
private void captureImage(WebDriver driver, String filePath, float quality) throws IOException {
JPEGImageWriteParam param = new JPEGImageWriteParam(Locale.getDefault());
param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
param.setCompressionQuality(quality);

// 150はミリ秒でスクロールを待つ時間、短すぎるとダメな模様
**ShootingStrategy ss = ShootingStrategies.viewportPasting(150); 

Screenshot screenshot = new AShot().shootingStrategy(ss).takeScreenshot(driver);**

ImageWriter writer = null;
try {
    writer = ImageIO.getImageWritersByFormatName("jpg").next();
    writer.setOutput(ImageIO.createImageOutputStream(new File(filePath)));
    writer.write(null, new IIOImage(screenshot.getImage(), null, null), param);
} finally {
    if (writer != null) {
        writer.dispose();
    }
}

}

when the project is running, ShootingStrategy ss.shottingArea are NULL!

how can i solve this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant