Google chrome extension 木偶演员无法在GitHub动作中启动

Google chrome extension 木偶演员无法在GitHub动作中启动,google-chrome-extension,puppeteer,github-actions,Google Chrome Extension,Puppeteer,Github Actions,我正在尝试使用Puppeter测试这个Chrome扩展。我的测试在本地运行良好,但在GitHub操作中不起作用。我怀疑问题在于运行Puppeter的GitHub操作环境,但我不太确定根本问题是什么 我尝试了所有linux-latest、windows-latest和macos-latest,用于config.yml的在选项上运行,它们给了我不同的错误消息: linux最新版本 Failed to launch the browser process! [2801:2801:060

我正在尝试使用Puppeter测试这个Chrome扩展。我的测试在本地运行良好,但在GitHub操作中不起作用。我怀疑问题在于运行Puppeter的GitHub操作环境,但我不太确定根本问题是什么

我尝试了所有
linux-latest
windows-latest
macos-latest
,用于
config.yml
选项上运行,它们给了我不同的错误消息:

linux最新版本

    Failed to launch the browser process!
    [2801:2801:0606/033446.894051:ERROR:browser_main_loop.cc(1468)] Unable to open X display.
    Received signal 11 SEGV_MAPERR 000000000000
    #0 0x5617d755b399 base::debug::CollectStackTrace()
    #1 0x5617d74bc2a3 base::debug::StackTrace::StackTrace()
    #2 0x5617d755af35 base::debug::(anonymous namespace)::StackDumpSignalHandler()
    #3 0x7efd5b4f6890 (/lib/x86_64-linux-gnu/libpthread-2.27.so+0x1288f)
    #4 0x5617d9f51f38 ChromeBrowserMainExtraPartsViewsLinux::~ChromeBrowserMainExtraPartsViewsLinux()
    #5 0x5617d7103140 ChromeBrowserMainParts::~ChromeBrowserMainParts()
    #6 0x5617d7102cfe ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux()
    #7 0x5617d57fc1bf content::BrowserMainLoop::~BrowserMainLoop()
    #8 0x5617d57fc2ce content::BrowserMainLoop::~BrowserMainLoop()
    #9 0x5617d5800c2b content::BrowserMainRunnerImpl::Shutdown()
    #10 0x5617d5800738 content::BrowserMainRunnerImpl::~BrowserMainRunnerImpl()
    #11 0x5617d57fbd30 content::BrowserMain()
    #12 0x5617d7086796 content::ContentMainRunnerImpl::RunServiceManager()
    #13 0x5617d70863c7 content::ContentMainRunnerImpl::Run()
    #14 0x5617d70e7ad1 service_manager::Main()
    #15 0x5617d7084631 content::ContentMain()
    #16 0x5617d4ada5ae ChromeMain
    #17 0x7efd54e61b97 __libc_start_main
    #18 0x5617d4ada3ea _start
      r8: 0000000000000000  r9: 0000000000000001 r10: 0000000000000002 r11: 00001471e8e09708
     r12: aaaaaaaaaaaaaaaa r13: 00001471e8df6a50 r14: 00001471e8e09878 r15: 00001471e8d52460
      di: 00001471e8e09840  si: 00001471e8ea4220  bp: 00007ffedc9b6d30  bx: 00001471e8e09840
      dx: 00001471e8ea4220  ax: 0000000000000000  cx: fffffffd4f415a7b  sp: 00007ffedc9b6d20
      ip: 00005617d9f51f38 efl: 0000000000010202 cgf: 002b000000000033 erf: 0000000000000004
     trp: 000000000000000e msk: 0000000000000000 cr2: 0000000000000000
    [end of stack trace]
    Calling _exit(1). Core file will not be generated.
    [0606/033446.978197:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox!
    Most likely you need to configure your SUID sandbox correctly

    TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

      at onClose (node_modules/puppeteer/lib/launcher/BrowserRunner.js:159:20)
      at Interface.helper_1.helper.addEventListener (node_modules/puppeteer/lib/launcher/BrowserRunner.js:149:65)
    net::ERR_BLOCKED_BY_CLIENT at chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html

> 20 |     await page.goto('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');

      at navigate (node_modules/puppeteer/lib/FrameManager.js:95:23)
        -- ASYNC --
      at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:94:19)
      at Page.goto (node_modules/puppeteer/lib/Page.js:476:53)
      at Page.goto (node_modules/puppeteer/lib/helper.js:95:27)
      at Object.beforeEach (tests/e2e.test.js:20:16)
    Timeout - Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:29:45)
这发生在
puppeter.launch()期间。我尝试了
--无沙盒
--禁用setuid沙盒
标志,但没有做任何事情

windows最新版本

    Failed to launch the browser process!
    [2801:2801:0606/033446.894051:ERROR:browser_main_loop.cc(1468)] Unable to open X display.
    Received signal 11 SEGV_MAPERR 000000000000
    #0 0x5617d755b399 base::debug::CollectStackTrace()
    #1 0x5617d74bc2a3 base::debug::StackTrace::StackTrace()
    #2 0x5617d755af35 base::debug::(anonymous namespace)::StackDumpSignalHandler()
    #3 0x7efd5b4f6890 (/lib/x86_64-linux-gnu/libpthread-2.27.so+0x1288f)
    #4 0x5617d9f51f38 ChromeBrowserMainExtraPartsViewsLinux::~ChromeBrowserMainExtraPartsViewsLinux()
    #5 0x5617d7103140 ChromeBrowserMainParts::~ChromeBrowserMainParts()
    #6 0x5617d7102cfe ChromeBrowserMainPartsLinux::~ChromeBrowserMainPartsLinux()
    #7 0x5617d57fc1bf content::BrowserMainLoop::~BrowserMainLoop()
    #8 0x5617d57fc2ce content::BrowserMainLoop::~BrowserMainLoop()
    #9 0x5617d5800c2b content::BrowserMainRunnerImpl::Shutdown()
    #10 0x5617d5800738 content::BrowserMainRunnerImpl::~BrowserMainRunnerImpl()
    #11 0x5617d57fbd30 content::BrowserMain()
    #12 0x5617d7086796 content::ContentMainRunnerImpl::RunServiceManager()
    #13 0x5617d70863c7 content::ContentMainRunnerImpl::Run()
    #14 0x5617d70e7ad1 service_manager::Main()
    #15 0x5617d7084631 content::ContentMain()
    #16 0x5617d4ada5ae ChromeMain
    #17 0x7efd54e61b97 __libc_start_main
    #18 0x5617d4ada3ea _start
      r8: 0000000000000000  r9: 0000000000000001 r10: 0000000000000002 r11: 00001471e8e09708
     r12: aaaaaaaaaaaaaaaa r13: 00001471e8df6a50 r14: 00001471e8e09878 r15: 00001471e8d52460
      di: 00001471e8e09840  si: 00001471e8ea4220  bp: 00007ffedc9b6d30  bx: 00001471e8e09840
      dx: 00001471e8ea4220  ax: 0000000000000000  cx: fffffffd4f415a7b  sp: 00007ffedc9b6d20
      ip: 00005617d9f51f38 efl: 0000000000010202 cgf: 002b000000000033 erf: 0000000000000004
     trp: 000000000000000e msk: 0000000000000000 cr2: 0000000000000000
    [end of stack trace]
    Calling _exit(1). Core file will not be generated.
    [0606/033446.978197:ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox!
    Most likely you need to configure your SUID sandbox correctly

    TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md

      at onClose (node_modules/puppeteer/lib/launcher/BrowserRunner.js:159:20)
      at Interface.helper_1.helper.addEventListener (node_modules/puppeteer/lib/launcher/BrowserRunner.js:149:65)
    net::ERR_BLOCKED_BY_CLIENT at chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html

> 20 |     await page.goto('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');

      at navigate (node_modules/puppeteer/lib/FrameManager.js:95:23)
        -- ASYNC --
      at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:94:19)
      at Page.goto (node_modules/puppeteer/lib/Page.js:476:53)
      at Page.goto (node_modules/puppeteer/lib/helper.js:95:27)
      at Object.beforeEach (tests/e2e.test.js:20:16)
    Timeout - Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.Error: Timeout - Async callback was not invoked within the 30000 ms timeout specified by jest.setTimeout.

      at mapper (node_modules/jest-jasmine2/build/queueRunner.js:29:45)
这两个超时错误发生在不同的地方

这是我的
beforeach()
,无法在GitHub上成功执行操作:

beforeEach (async () => {
    browser = await puppeteer.launch({
      headless: false,
      args: [
        `--disable-extensions-except=${extensionPath}`,
        `--load-extension=${extensionPath}`
      ],
      slowMo: 50
    });
    page = await browser.newPage();
    await page.goto('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');
  });
这是我的
config.yml
jobs
部分:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Use Node.js 
      uses: actions/setup-node@v1

    - name: Install dependencies
      run: npm ci

    - name: Run Extension
      run: npm run build  

    - name: Run tests
        run: npm run test
我正在使用最新版本的Puppeter(v3.1.0)和Jest(v26.0.1)来运行我的测试文件。我的其他测试(仅使用Jest的单元测试)运行时没有问题。扩展使用Vue.js,但我认为这无关紧要

编辑

在本地计算机上运行
headless:true
,也会出现错误。这是Windows 10,它很重要:

    net::ERR_ABORTED at chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html

    > 23 |     await page.goto('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');

      at navigate (node_modules/puppeteer/lib/FrameManager.js:120:37)
      at FrameManager.navigateFrame (node_modules/puppeteer/lib/FrameManager.js:94:17)
      at Frame.goto (node_modules/puppeteer/lib/FrameManager.js:406:12)
      at Page.goto (node_modules/puppeteer/lib/Page.js:672:12)
      at Object.<anonymous> (tests/e2e.test.js:23:5)
        -- ASYNC --
      at Frame.<anonymous> (node_modules/puppeteer/lib/helper.js:111:15)
      at Page.goto (node_modules/puppeteer/lib/Page.js:672:49)
      at Page.goto (node_modules/puppeteer/lib/helper.js:112:23)
      at Object.<anonymous> (tests/e2e.test.js:23:16)
net::ERR\u在chrome上中止-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html
>23 |等待页面。转到('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');
导航(node_modules/puppeter/lib/FrameManager.js:120:37)
在FrameManager.navigateName(node_modules/puppeter/lib/FrameManager.js:94:17)
在Frame.goto(node_modules/puppeter/lib/FrameManager.js:406:12)
在Page.goto(node_modules/puppeter/lib/Page.js:672:12)
反对。(tests/e2e.test.js:23:5)
--异步的--
在画面上。(node_modules/puppeter/lib/helper.js:111:15)
在Page.goto(node_modules/puppeter/lib/Page.js:672:49)
在Page.goto(node_modules/puppeter/lib/helper.js:112:23)
反对。(tests/e2e.test.js:23:16)

我建议进行以下更改:

代码中的

beforeach(异步()=>{
browser=wait puppeter.launch({
无头:是的,
args:[
`--没有沙箱`
`--禁用setuid沙盒`
`--禁用扩展,除了=${extensionPath}`,
`--加载扩展=${extensionPath}`
],
slowMo:50
});
page=wait browser.newPage();
等待页面。转到('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');
});
正如Sirko所建议的:如果您在GitHub操作中运行Puppeter,请始终使用
headless:true
,“headful”铬会在工作流中运行时出现问题

--无沙盒
--禁用setuid沙盒
可能也是必需的,即使它们以前没有解决您的问题,也不要删除它们

在config.yml中:

如果您想使用Puppeter 3+,则需要安装
libgbm1
,以便在unix上无头运行它()

如果您不需要所有最新的Puppeter 3功能:您可以降级到2.1.1,这不需要额外的库


编辑:关于
headless:true的新信息在本地失败后
根据这一问题,最有可能的是:

Chrome/Chrome中的扩展目前仅在非无头模式下工作

默认情况下,您不能在Github操作中运行Puppeter headful,只能headless。

解决方案:

可以帮助您的是一个名为:

按照“操作”页面上的说明配置
config.yml
后,您需要确保按如下方式启动Puppeter:

beforeach(异步()=>{
browser=wait puppeter.launch({
executablePath:process.env.puppeter\u EXEC\u PATH,//由docker容器设置
无头:错,
args:[
`--禁用扩展,除了=${extensionPath}`,
`--加载扩展=${extensionPath}`
],
slowMo:50
});
page=wait browser.newPage();
等待页面。转到('chrome-extension://acdcddifhaiiiagbodmcnebcgdmlgdkl/popup/popup.html');
});

因此,它将在Github操作和本地运行。

我想您需要在
无头
模式下运行。我忘了提到我尝试了
无头:true
,但它无法在本地机器上运行。我在原来的问题中补充了更多的信息。我明白了。你查过这个了吗?根据这一点,问题似乎是:“(e)Chrome/Chrome中的xtensions目前仅在非无头模式下工作。”,而默认情况下,您无法在Github Actions headful、only headless中运行Puppeter。这项名为GH的行动能起到帮助作用。我用这句话扩展了我的答案。是的,我尝试了两种不同的方法来帮助木偶演员运行头部模式,但都不起作用。另一个正在开发另一个Chrome扩展的人说它和他的应用程序一起工作,所以我认为我的问题出在其他地方。对于这篇文章,我认为你的答案应该对其他人有好处。非常感谢。