<commit_before>package org.jbehave.web.selenium;

import org.jbehave.core.annotations.AfterScenario;
import org.jbehave.core.annotations.AfterScenario.Outcome;
import org.jbehave.core.failures.UUIDExceptionWrapper;

/**
 * WebDriverSteps that save screen-shot upon failure in a scenario outcome.
 * Not all WebDriver implement screen-shot capability
 */
public class WebDriverScreenshotOnFailure extends WebDriverSteps {

    public WebDriverScreenshotOnFailure(WebDriverProvider driverProvider) {
        super(driverProvider);
    }

    @AfterScenario(uponOutcome = Outcome.FAILURE)
    public void afterScenarioFailure(UUIDExceptionWrapper uuidWrappedFailure) throws Exception {

        String screenshotPath = "target/jbehave/screenshots/failed-scenario-" + uuidWrappedFailure.getUUID() + ".png";
        if ( driverProvider.saveScreenshotTo(screenshotPath) ){
            System.out.println("Screenshot has been saved to '" + screenshotPath +"'");
        } else {
            System.out.println(driverProvider.get().getClass().getName() + " does not support taking screenshots.");
        }
    }

}<commit_msg>refactoring to allow the users to modify output directory for screenshots<commit_after>package org.jbehave.web.selenium;

import org.jbehave.core.annotations.AfterScenario;
import org.jbehave.core.annotations.AfterScenario.Outcome;
import org.jbehave.core.failures.UUIDExceptionWrapper;

/**
 * WebDriverSteps that save screen-shot upon failure in a scenario outcome.
 * Not all WebDriver implementations screen-shot capability
 */
public class WebDriverScreenshotOnFailure extends WebDriverSteps {

    public WebDriverScreenshotOnFailure(WebDriverProvider driverProvider) {
        super(driverProvider);
    }

    @AfterScenario(uponOutcome = Outcome.FAILURE)
    public void afterScenarioFailure(UUIDExceptionWrapper uuidWrappedFailure) throws Exception {

        String screenshotPath = getScreenShotRootPath() + "/failed-scenario-" + uuidWrappedFailure.getUUID() + ".png";
        if ( driverProvider.saveScreenshotTo(screenshotPath) ) {
            System.out.println("Screenshot has been saved to '" + screenshotPath +"'");
        } else {
            System.out.println(driverProvider.get().getClass().getName() + " does not support taking screenshots.");
        }
    }

    /**
     * The root path for the screenshots.
     * Defaults to "target/jbehave/screenshots"
     * @return the root path.
     */
    public String getScreenShotRootPath() {
        return "target/jbehave/screenshots";
    }

}
{'fraction_non_alphanumeric': 0.09499408750492708, 'fraction_numerical': 0.0, 'mean_word_length': 3.9186046511627906, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2374884', 'n_tokens_mistral': 726, 'n_tokens_neox': 703, 'n_words': 151}