testcafe 错误无法打开“chrome:headless”浏览器

问题描述 投票:0回答:1

我有一个 Maven 项目,在集成测试阶段与 testcafe 运行端到端测试

我在 aws codepipeline 上获得了

ERROR Unable to open the "chrome:headless" browser
2 天,在此之前,管道没有任何更改,它已成功运行。

testcafe 命令:

testcafe chrome:headless

要在 Maven 项目中运行 npm 命令,我使用

com.github.eirslett:frontend-maven-plugin:1.15.0
插件,这是我的管道集成测试阶段的一部分。

[INFO] > [email protected] test-shop-chrome
[INFO] > testcafe chrome:headless
[INFO] 
[INFO] Using CONFIG: {"baseUrl":"http://localhost:18888"}
[INFO] ERROR Unable to open the "chrome:headless" browser due to the following error:
[INFO] 
[INFO] Error: No inspectable targets
[INFO]     at defaultTarget (/codebuild/output/src123/src/git-codecommit.eu-central-1.amazonaws.com/v1/repos/shop/src/test/e2e/node_modules/chrome-remote-interface/lib/chrome.js:48:23)
[INFO]     at Chrome._fetchDebuggerURL (/codebuild/output/src123/src/git-codecommit.eu-central-1.amazonaws.com/v1/repos/shop/src/test/e2e/node_modules/chrome-remote-interface/lib/chrome.js:193:28)
[INFO]     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[INFO]     at Chrome._start (/codebuild/output/src123/src/git-codecommit.eu-central-1.amazonaws.com/v1/repos/shop/src/test/e2e/node_modules/chrome-remote-interface/lib/chrome.js:140:25)
[INFO] 
[INFO] Type "testcafe -h" for help.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  03:10 min
[INFO] Finished at: 2024-02-23T10:29:34Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.15.0:npm (e2e-npm-test) on project shop: Failed to run task: 'npm run test-shop-chrome' failed. org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.eirslett:frontend-maven-plugin:1.15.0:npm (e2e-npm-test) on project shop: Failed to run task
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute2 (MojoExecutor.java:333)
    at org.apache.maven.lifecycle.internal.MojoExecutor.doExecute (MojoExecutor.java:316)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:212)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:174)

首先我以为Chrome安装有问题,结果安装成功了。

后来我更新了frontend-maven-plugin版本,也没有任何变化。

我不确定可以更改什么,任何帮助将不胜感激。

java maven testcafe aws-codepipeline google-chrome-headless
1个回答
0
投票

您应该提供您的代码。所以我可以告诉你如何在无头模式下打开chrome。您可以交叉验证您的做法

from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument("--headless=new")

请给我反馈,因为这是我第一次回答

© www.soinside.com 2019 - 2024. All rights reserved.