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

Write screenshot to file #333

Merged
merged 14 commits into from
Dec 26, 2019
Merged

Write screenshot to file #333

merged 14 commits into from
Dec 26, 2019

Conversation

negiDharmendra
Copy link
Contributor

@negiDharmendra negiDharmendra commented Dec 17, 2019

  • Changed default screenshot grabber to write to file and return file path.
  • Depricate existing custom screenshot grabber API contract.
  • Create a new API contact for custom screenshot grabber to write the screenshot into file and returning file path instead of screenhsot bytes.
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import com.thoughtworks.gauge.screenshot.CustomScreenshotWriter;

import driver.DriverFactory;

public class CustomScreenshotGrabber implements CustomScreenshotWriter {

    @Override
    public String takeScreenshot() {
        TakesScreenshot driver = (TakesScreenshot) DriverFactory.getDriver();
        File screenshotFile = new File(Paths.get(System.getenv("gauge_screenshots_dir"), "screenshot-1.png").toString());
        File tmpFile = driver.getScreenshotAs(OutputType.FILE);
        try {
            FileUtils.copyFile(tmpFile, screenshotFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return screenshotFile.getName();
    }

}

@gaugebot gaugebot bot added the cla-signed label Dec 17, 2019
@gaugebot gaugebot bot requested a review from nehashri December 17, 2019 04:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants