首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >启用源集合时如何通过PLAYWRIGHT_JAVA_SRC环境变量设置源目录

启用源集合时如何通过PLAYWRIGHT_JAVA_SRC环境变量设置源目录
EN

Stack Overflow用户
提问于 2022-06-06 12:19:07
回答 1查看 958关注 0票数 1

我正在尝试使用java运行我的第一个剧作家跟踪,并且我得到了下面的错误,我不知道我遗漏了什么,我正在用Intlij运行mu代码

代码语言:javascript
复制
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/");

我的错误越来越少

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 2022-06-13 13:22:09

要让剧作家将您的测试源链接到跟踪日志,它需要知道源文件夹的位置,如文档这里中所描述的那样。

例如,在Powershell中,您可以这样设置它:

代码语言:javascript
复制
$env:PLAYWRIGHT_JAVA_SRC="src/test/java"

这将向跟踪和检查人员添加源。

如果不需要源,则可以在创建上下文实例时禁用它:

代码语言:javascript
复制
context.tracing().start(new Tracing.StartOptions()
       .setScreenshots(true)
       .setSnapshots(true)
       .setSources(false));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/72517605

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档