Skip to content

AllureSelenide should use Selenide's screenshot implementation instead of Selenium WebDriver's implementation #1439

Description

@USSQA

What problem should this solve?

Currently, when AllureSelenide takes a screenshot after an assertion failure, it uses WebDriverRunner.getWebDriver() to fetch the underlying Selenium WebDriver and take a screenshot. This means that plugin libraries like com.codeborne:selenide-full-screenshot which change the Photographer don't apply to screenshots added to Allure.

What would you like to happen?

io.qameta.allure.selenide.AllureSelenide.getScreenshotBytes() should use Selenide.screenshot(OutputType.BYTES) instead of the current implementation: ((TakesScreenshot) WebDriverRunner.getWebDriver()).getScreenshotAs(OutputType.BYTES), so that Selenide plugins like selenide-full-screenshot apply correctly and consistently across a test suite and reports.

Alternatives considered

We currently workaround this by using the following custom AllureSelenide subclass, which demonstrates how the Selenide.screenshot() method can effectively replace the direct WebDriver approach:

public final class AllureSelenideFullScreenshot extends AllureSelenide {

    public AllureSelenideFullScreenshot() {
        super.screenshots(false); // disable parent class screenshot behavior; full-page screenshot is taken instead
    }

    @Override
    public void afterEvent(final @NonNull LogEvent event) {
        if (event.getStatus().equals(LogEvent.EventStatus.FAIL)) {
            byte[] screenshot = Selenide.screenshot(OutputType.BYTES);
            if (screenshot != null) {
                Allure.attachment("Screenshot", "image/png", new ByteArrayInputStream(screenshot), AttachmentOptions.empty());
            }
        }
        super.afterEvent(event);
    }
}

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions