0

I'm trying to run my Playwright trace using java and I'm getting the below error, I'm not sure what I'm missing out and I'm running my code in 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();

I am getting the following error

[RemoteTestNG] detected TestNG version 7.4.0 FAILED CONFIGURATION: @BeforeMethod doLaunchBrowser com.microsoft.playwright.PlaywrightException: Source root directory must be specified via PLAYWRIGHT_JAVA_SRC environment variable when source collection is enabled at com.microsoft.playwright.impl.TracingImpl.startImpl(TracingImpl.java:94) at com.microsoft.playwright.impl.TracingImpl.lambda$start$0(TracingImpl.java:68) at com.microsoft.playwright.impl.LoggingSupport.lambda$withLogging$0(LoggingSupport.java:36) at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:47) at com.microsoft.playwright.impl.ChannelOwner.withLogging(ChannelOwner.java:85) at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35) at com.microsoft.playwright.impl.TracingImpl.start(TracingImpl.java:68) at com.united_arab_bank.base.BasePage.doLaunchBrowser(BasePage.java:91) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:568) at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:133) at org.testng.internal.MethodInvocationHelper.invokeMethodConsideringTimeout(MethodInvocationHelper.java:62) at org.testng.internal.ConfigInvoker.invokeConfigurationMethod(ConfigInvoker.java:385) at org.testng.internal.ConfigInvoker.invokeConfigurations(ConfigInvoker.java:321) at org.testng.internal.TestInvoker.runConfigMethods(TestInvoker.java:700) at org.testng.internal.TestInvoker.invokeMethod(TestInvoker.java:527) at org.testng.internal.TestInvoker.invokeTestMethod(TestInvoker.java:173) at org.testng.internal.MethodRunner.runInSequence(MethodRunner.java:46) at org.testng.internal.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:824) at org.testng.internal.TestInvoker.invokeTestMethods(TestInvoker.java:146) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:128) at java.base/java.util.ArrayList.forEach(ArrayList.java:1511) at org.testng.TestRunner.privateRun(TestRunner.java:794) at org.testng.TestRunner.run(TestRunner.java:596) at org.testng.SuiteRunner.runTest(SuiteRunner.java:377) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:371) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:332) at org.testng.SuiteRunner.run(SuiteRunner.java:276) at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:53) at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:96) at org.testng.TestNG.runSuitesSequentially(TestNG.java:1212) at org.testng.TestNG.runSuitesLocally(TestNG.java:1134) at org.testng.TestNG.runSuites(TestNG.java:1063) at org.testng.TestNG.run(TestNG.java:1031) at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115) at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

1 Answer 1

0

I faced same issue on macOS.

For mac ONLY, add the following line to ~/.zshrc file.

export PLAYWRIGHT_JAVA_SRC=/usr/libexec/java_home

Don't forget to close your current terminal and open a new one in order to read the updated env variables.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.