Selenide 7.6.0 录像机无法工作/实施错误

问题描述 投票:0回答:1

从一个月前开始,我终于抽出时间升级Selenide版本,并对测试录制的新功能产生了兴趣。

我想在我的代码之一中实现它: 硒化物-JUnit5-黄瓜 硒化物测试NG-黄瓜

不幸的是,两次尝试都以失败告终。按照文档,主题似乎很简单,但我无法弄清楚到底需要做什么才能使其以最简单的形式工作。

黄瓜跑者

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

步骤定义

@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 我没有看到任何可以处理视频记录的方法。比如视频启用等。

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();
    }
}
java testing cucumber junit5 selenide
1个回答
0
投票

虽然您使用 JUnit 5 运行 Cucumber,但这并不意味着您可以使用扩展。

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

与以前版本的 JUnit 不同,JUnit 5 由来自三个不同子项目的多个不同模块组成。

JUnit 5 = JUnit 平台 + JUnit Jupiter + JUnit Vintage

这里 JUnit Jupiter、JUnit Vintage 和 Cucumber 是 JUnit 平台上的测试引擎。扩展是一个 Jupiter 概念,只能与 JUnit Jupiter 一起使用。

幸运的是,录像机扩展相对简单。如果您查看来源 您可以使用

@BeforeAll
@AfterAll
@Before
@After
钩子将 VideoRecorder 与 Cucumber 结合使用。

© www.soinside.com 2019 - 2024. All rights reserved.