javatestingcucumberjunit5selenide

Selenide 7.6.0 Video recorder not working / wrong implementation


I finally got around to upgrading the Selenide version from a month ago, and I got interested in the new feature regarding test recording.

I wanted to implement it in one of my codes: Selenide-JUnit5-Cucumber Selenide-TestNG-Cucumber

Unfortunately, both attempts ended with a failure. Following the documentation, it seems the topic is simple, but I can't figure out what exactly needs to be done to make it work in the simplest possible form.

CucumberRunner

@EnableVideo
    @ExtendWith(VideoRecorderExtension.class)
    public class RunCucumberTests
    {
    
    }

StepDefinition

@ExtendWith(VideoRecorderExtension.class)
@EnableVideo
public class StarterStep
{
    @BeforeAll 
    static void setUp() {
        // Konfiguracja ścieżki do nagrań

        System.setProperty("selenide.video.directory", "target/videos"); 
        System.setProperty("selenide.video.enabled", "true"); 

    }
    @Video
    @Given("Start testing")
    public void openBrowser(){
        open("https://www.saucedemo.com/");
    }

Selenide Configuration.class i don't see there any methods which can handle video records. like video enable etc.

package com.codeborne.selenide;

import org.jspecify.annotations.Nullable;
import org.openqa.selenium.MutableCapabilities;

public class Configuration {
    private static final SelenideConfig defaults = new SelenideConfig();
    public static String baseUrl;
    public static long timeout;
    public static long pollingInterval;
    /** @deprecated */
    @Deprecated
    public static boolean holdBrowserOpen;
    public static boolean reopenBrowserOnFail;
    public static String browser;
    public static @Nullable String browserVersion;
    public static @Nullable String remote;
    public static @Nullable String browserSize;
    public static @Nullable String browserPosition;
    public static MutableCapabilities browserCapabilities;
    public static String pageLoadStrategy;
    public static long pageLoadTimeout;
    public static boolean clickViaJs;
    public static boolean screenshots;
    public static boolean savePageSource;
    public static String reportsFolder;
    public static String downloadsFolder;
    public static @Nullable String reportsUrl;
    public static boolean fastSetValue;
    public static TextCheck textCheck;
    public static SelectorMode selectorMode;
    public static AssertionMode assertionMode;
    public static FileDownloadMode fileDownload;
    public static boolean proxyEnabled;
    public static @Nullable String proxyHost;
    public static int proxyPort;
    public static boolean webdriverLogsEnabled;
    public static boolean headless;
    public static @Nullable String browserBinary;
    public static long remoteReadTimeout;
    public static long remoteConnectionTimeout;

    public Configuration() {
    }

    public static SelenideConfig config() {
        return (new SelenideConfig()).baseUrl(baseUrl).timeout(timeout).pollingInterval(pollingInterval).holdBrowserOpen(holdBrowserOpen).reopenBrowserOnFail(reopenBrowserOnFail).browser(browser).browserVersion(browserVersion).remote(remote).browserSize(browserSize).browserPosition(browserPosition).browserCapabilities(browserCapabilities).pageLoadStrategy(pageLoadStrategy).pageLoadTimeout(pageLoadTimeout).clickViaJs(clickViaJs).screenshots(screenshots).savePageSource(savePageSource).reportsFolder(reportsFolder).downloadsFolder(downloadsFolder).reportsUrl(reportsUrl).fastSetValue(fastSetValue).textCheck(textCheck).selectorMode(selectorMode).assertionMode(assertionMode).fileDownload(fileDownload).proxyEnabled(proxyEnabled).proxyHost(proxyHost).proxyPort(proxyPort).webdriverLogsEnabled(webdriverLogsEnabled).headless(headless).browserBinary(browserBinary).remoteReadTimeout(remoteReadTimeout).remoteConnectionTimeout(remoteConnectionTimeout);
    }

    static {
        baseUrl = defaults.baseUrl();
        timeout = defaults.timeout();
        pollingInterval = defaults.pollingInterval();
        holdBrowserOpen = defaults.holdBrowserOpen();
        reopenBrowserOnFail = defaults.reopenBrowserOnFail();
        browser = defaults.browser();
        browserVersion = defaults.browserVersion();
        remote = defaults.remote();
        browserSize = defaults.browserSize();
        browserPosition = defaults.browserPosition();
        browserCapabilities = defaults.browserCapabilities();
        pageLoadStrategy = defaults.pageLoadStrategy();
        pageLoadTimeout = defaults.pageLoadTimeout();
        clickViaJs = defaults.clickViaJs();
        screenshots = defaults.screenshots();
        savePageSource = defaults.savePageSource();
        reportsFolder = defaults.reportsFolder();
        downloadsFolder = defaults.downloadsFolder();
        reportsUrl = defaults.reportsUrl();
        fastSetValue = defaults.fastSetValue();
        textCheck = defaults.textCheck();
        selectorMode = defaults.selectorMode();
        assertionMode = defaults.assertionMode();
        fileDownload = defaults.fileDownload();
        proxyEnabled = defaults.proxyEnabled();
        proxyHost = defaults.proxyHost();
        proxyPort = defaults.proxyPort();
        webdriverLogsEnabled = defaults.webdriverLogsEnabled();
        headless = defaults.headless();
        browserBinary = defaults.browserBinary();
        remoteReadTimeout = defaults.remoteReadTimeout();
        remoteConnectionTimeout = defaults.remoteConnectionTimeout();
    }
}

Solution

  • While your are using JUnit 5 to run Cucumber that does not mean you can use extensions.

    https://junit.org/junit5/docs/current/user-guide/#overview-what-is-junit-5

    Unlike previous versions of JUnit, JUnit 5 is composed of several different modules from three different sub-projects.

    JUnit 5 = JUnit Platform + JUnit Jupiter + JUnit Vintage

    Here JUnit Jupiter, JUnit Vintage and Cucumber are test engines on the JUnit Platform. And extensions are a Jupiter concept that can only be used with JUnit Jupiter.

    Fortunately the video recorder extensions is relatively simple. If you look at the source you can probably use the VideoRecorder with Cucumber using the @BeforeAll, @AfterAll, @Before and @After hooks.