【问题标题】:How to set Playwright Source root directory via PLAYWRIGHT_JAVA_SRC environment variable when source collection is enabled -How to set it for linux启用源代码收集时如何通过 PLAYWRIGHT_JAVA_SRC 环境变量设置 Playwright 源代码根目录 - 如何为 linux 设置它
【发布时间】:2023-01-05 02:47:29
【问题描述】:

我正在尝试使用 java 运行我的 Playwright 跟踪,但出现以下错误,我不确定我错过了什么,我在 eclipse 中运行我的代码

final Browser.NewContextOptions browserContextOptions = new Browser.NewContextOptions().setIgnoreHTTPSErrors(true).setViewportSize(width,height);
        context = browser.newContext(browserContextOptions);
        //context = browser.newContext(new Browser.NewContextOptions().setViewportSize(width, height));

        // Start tracing before creating / navigating a page.
        context.tracing().start(new Tracing.StartOptions()
                .setScreenshots(true)
                .setSnapshots(true)
                .setSources(true));
        page = context.newPage();

我收到以下错误

[RemoteTestNG] 检测到 TestNG 版本 7.4.0 配置失败: @BeforeMethod doLaunchBrowser com.microsoft.playwright.PlaywrightException: 源根目录 必须通过 PLAYWRIGHT_JAVA_SRC 环境变量指定 源集合启用于 com.microsoft.playwright.impl.TracingImpl.startImpl(TracingImpl.java:94) 在 com.microsoft.playwright.impl.TracingImpl.lambda$start$0(TracingImpl.java:68) 在 com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36) 在 com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47) 在 com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:85) 在 com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35) 在 com.microsoft.playwright.impl.TracingImpl.start(TracingImpl.java:68) 在 com.united_arab_bank.base.BasePage.doLaunchBrowser(BasePage.java:91) 在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native 方法)在 java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) 在 java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在 java.base/java.lang.reflect.Method.invoke(Method.java:568) 处 org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133) 在 org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62) 在 org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385) 在 org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321) 在 org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700) 在 org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527) 在 org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173) 在 org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) 在 org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824) 在 org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146) 在 org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) 在 org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) 在 java.base/java.util.ArrayList.forEach(ArrayList.java:1511) org.testng.TestRunner.privateRun(TestRunner.java:794)在 org.testng.TestRunner.run(TestRunner.java:596)在 org.testng.SuiteRunner.runTest(SuiteRunner.java:377) 在 org.testng.SuiteRunner.runSequentially (SuiteRunner.java:371) 在 org.testng.SuiteRunner.privateRun(SuiteRunner.java:332)在 org.testng.SuiteRunner.run(SuiteRunner.java:276)在 org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53)在 org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96)在 org.testng.TestNG.runSuitesSequentially(TestNG.java:1212)在 org.testng.TestNG.runSuitesLocally(TestNG.java:1134) 在 org.testng.TestNG.runSuites(TestNG.java:1063)在 org.testng.TestNG.run(TestNG.java:1031) 在 org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) 在 org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) 在 org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

【问题讨论】:

    标签: java


    【解决方案1】:

    我在 mac 上遇到了同样的问题。

    我将以下行添加到 ~/.zshrc 文件并且它起作用了!

    export PLAYWRIGHT_JAVA_SRC=/usr/libexec/java_home

    不要忘记关闭当前终端并打开一个新终端以读取更新的环境变量。

    【讨论】:

      猜你喜欢
      • 2022-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-28
      相关资源
      最近更新 更多