如何通过playwright_java_src环境变量设置源根目录。
我正在尝试使用Java运行我的第一个剧作家跟踪,并且我要在下面进行错误,我不确定我错过了什么,并且我正在Intlij中运行MU代码,
Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
BrowserContext browserContext = browser.newContext();
browserContext.tracing().start(new Tracing.StartOptions().setScreenshots(true).setSnapshots(true).setSources(true));
Page page = browser.newPage();
page.navigate("https://www.saucedemo.com/");
我的错误是低于错误
Exception in thread "main" 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:95)
at com.microsoft.playwright.impl.TracingImpl.lambda$start$0(TracingImpl.java:69)
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:79)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
at com.microsoft.playwright.impl.TracingImpl.start(TracingImpl.java:69)
at Sample.main(Sample.java:12)
I'm trying to run my first Playwright trace using java and i'm getting below error, I'm not sure what i'm missing out and I'm running mu code in Intlij
Playwright playwright = Playwright.create();
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions().setHeadless(false));
BrowserContext browserContext = browser.newContext();
browserContext.tracing().start(new Tracing.StartOptions().setScreenshots(true).setSnapshots(true).setSources(true));
Page page = browser.newPage();
page.navigate("https://www.saucedemo.com/");
I'm getting below error
Exception in thread "main" 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:95)
at com.microsoft.playwright.impl.TracingImpl.lambda$start$0(TracingImpl.java:69)
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:79)
at com.microsoft.playwright.impl.LoggingSupport.withLogging(LoggingSupport.java:35)
at com.microsoft.playwright.impl.TracingImpl.start(TracingImpl.java:69)
at Sample.main(Sample.java:12)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使剧作家将您的测试源链接到所需的跟踪日志,它需要知道文档中所述的源文件夹的位置在这里。
例如,在PowerShell中,您可以这样设置:
这将把源添加到跟踪和检查员中。
如果您不需要来源,则可以在创建上下文实例时将其禁用:
For Playwright to link your test sources to the trace log it needs to know the location of the source folder as described in the documentation here.
For example in Powershell you can set it like this:
This will add the sources to the trace and to the Inspector.
If you do not need the sources, you can just disable it when you create the context instance: