空手道:如何使用 sudo 实现 Linux 使用的 --no-sandbox 标头

2023-12-04

我想在 jenkins 中为 UI 测试自动化设置一个无头 chrome 驱动程序。

但要运行测试命令

sudo -E java -jar karate-0.9.3.jar karate_GUI.feature

我必须以 root 身份运行,并且需要 --no-sandbox,如果我没记错的话,v0.9.3 中仍然不支持它。

如果可能,我如何包含 --no-sandbox 选项?

我检查了https://intuit.github.io/karate/karate-core/并且没有 --no-sandbox 选项。

我的功能配置:

Feature: message end-point
Background:
* configure driver = { type: 'chrome', executable: '/usr/bin/google-chrome', headless: true }
# Login Url
* def browserManagementUrl = 'http://localhost:8000/login/'

Scenario: GUI Testing for Login page
    Given driver browserManagementUrl
    And eval driver.input('input[name=name]', 'admin')
    And eval driver.input('input[name=password]', 'adminadmin')
    And driver.submit('#login-button')
    When driver.submit('#login-button')
    Then match driver.location == 'http://localhost:8000/select/'

linux 命令及其结果

sudo -E java -jar karate-0.9.3.jar karate_GUI.feature
07:15:56.296 [main] INFO  com.intuit.karate.Main - Karate version: 0.9.3
07:15:57.345 [ForkJoinPool-1-worker-1] WARN  com.intuit.karate - skipping bootstrap configuration: could not find or read file: classpath:karate-config.js
07:15:57.418 [chrome_1560323757416] DEBUG c.i.k.driver.chrome_1560323757416 - command: [/usr/bin/google-chrome, --remote-debugging-port=9222, --no-first-run, --user-data-dir=/var/jenkins_home/workspace/my-karate_GUI@2/integrations/target/chrome_1560323757416, --disable-popup-blocking, --headless]
07:15:57.419 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - poll attempt #0 for port to be ready - localhost:9222
07:15:57.420 [chrome_1560323757416] DEBUG c.i.k.driver.chrome_1560323757416 - env PATH: /sbin:/bin:/usr/sbin:/usr/bin
07:15:57.423 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - sleeping for millis: 250
07:15:57.674 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - poll attempt #1 for port to be ready - localhost:9222
07:15:57.675 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - sleeping for millis: 250
07:15:57.793 [chrome_1560323757416] DEBUG c.i.k.driver.chrome_1560323757416 - [0612/071557.791933:ERROR:zygote_host_impl_linux.cc(89)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
07:15:57.810 [chrome_1560323757416] DEBUG c.intuit.karate.shell.CommandThread - command complete, exit code: 1 - [/usr/bin/google-chrome, --remote-debugging-port=9222, --no-first-run, --user-data-dir=/var/jenkins_home/workspace/my-karate_GUI@2/integrations/target/chrome_1560323757416, --disable-popup-blocking, --headless]
07:15:57.926 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - poll attempt #2 for port to be ready - localhost:9222
07:15:57.927 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - sleeping for millis: 250
07:15:58.178 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - poll attempt #3 for port to be ready - localhost:9222
[...]
07:16:02.206 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - poll attempt #19 for port to be ready - localhost:9222
07:16:02.207 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - sleeping for millis: 250
07:16:02.848 [ForkJoinPool-1-worker-1] DEBUG c.i.k.driver.chrome_1560323757416 - request:
1 > GET http://localhost:9222/json
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Host: localhost:9222
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_212)

07:16:02.862 [ForkJoinPool-1-worker-1] ERROR c.i.k.driver.chrome_1560323757416 - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 13 milliseconds for URL: http://localhost:9222/json
07:16:02.863 [ForkJoinPool-1-worker-1] ERROR c.i.k.driver.chrome_1560323757416 - http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
07:16:02.918 [pool-1-thread-1] INFO  com.intuit.karate.Runner - <<fail>> feature 1 of 1: karate_GUI.feature
---------------------------------------------------------
feature: karate_GUI.feature
report: target/karate_GUI.json
scenarios:  1 | passed:  0 | failed:  1 | time: 5.4993
---------------------------------------------------------
Karate version: 0.9.3
======================================================
elapsed:   6.39 | threads:    1 | thread time: 5.50
features:     1 | ignored:    0 | efficiency: 0.86
scenarios:    1 | passed:     0 | failed: 1
======================================================
failed features:
karate_GUI: karate_GUI.feature:8 -
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused)

Exception in thread "main" picocli.CommandLine$ExecutionException: there are test failures
    at com.intuit.karate.Main$1.handleExecutionException(Main.java:133)
    at picocli.CommandLine.parseWithHandlers(CommandLine.java:1157)
    at com.intuit.karate.Main.main(Main.java:139)

我想您确实知道 UI 自动化部分仍处于实验阶段,是的,我认为我们不支持--no-sandbox- 请随时开票并帮助我们提供一些链接,说明为什么需要此功能、它的用途等。

建议的解决方法是您可以传递一个批处理文件作为executable的关键configure driver称呼。在此批处理文件中,您可以使用所需的任何自定义参数或参数调用 chromedriver 可执行文件。

请告诉我们这是否有效。在我看来,传递任何自定义标志的方法是一个必要的功能,请将其添加到您的功能请求中。

编辑:对于那些将来登陆这里的人,我不是 100% 确定,但也许这里的信息会有所帮助:https://github.com/intuit/karate/issues/1134#issuecomment-638990087

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

空手道:如何使用 sudo 实现 Linux 使用的 --no-sandbox 标头 的相关文章

随机推荐

  • 平均库存历史表

    我有一个表格 用于跟踪某些商店和产品的库存随时间的变化 该值是绝对库存 但我们仅在库存发生变化时插入新行 这种设计是为了保持表较小 因为预计它会快速增长 这是一个示例架构和一些测试数据 CREATE TABLE stocks id seri
  • DbAcl::check() - 权限检查中 ARO/ACO 节点查找失败。

    我正在使用 cakephp 并使用 acl 但我面临这个错误 DbAcl check Failed ARO ACO node lookup in permissions check 感谢帮助 您可能已向控制器添加了操作 但未更新aco桌子
  • CSS 属性中“auto”值的含义是什么?

    是什么意思autoCSS 属性的值 当 CSS 属性的值设置为时会发生什么auto 上述财产的价值已调整自动地根据元素的内容或上下文 例如 一个块级元素height auto随着包含更多文本 它会变得更高 再举一个例子 一个块元素margi
  • 安装后运行 kubectl 命令 Helm

    我想运行一些kubectl用于验证 Helm 图表的集群安装后的命令 我找不到与此相关的任何文档 在 Helm 中 存在将注释显示为一部分的概念NOTES txt但看起来您不能在该阶段运行任何命令 目前 Helm 无法做到这一点吗 您可以定
  • 将 morgan 与 logger 一起使用时,stream.write 不是一个函数

    基本上我正在尝试使用摩根和温斯顿为nodejs实现记录器 当我尝试使用 morgan 时 抛出stream write 错误不是一个函数 因为我想获取文件名 所以我传递模块 从模块对象有一个名为文件名的属性 下面是我的代码 温斯顿 js c
  • 如何将 Vim 中每行开头的空格数量减半?

    有人可以告诉我如何在 Vim 中执行与此映射相反的操作 nnoremap
  • 默认指定的非类型模板参数值时出现“使用类模板需要模板参数”错误

    编译这个 include
  • 调用弹出窗口的“.ShowDialog()”时 WPF 应用程序关闭

    首先 我想解释一下我要做什么 我正在开发一个学习应用程序来向学生展示一些卡片 我有CardPack类是一组卡片 为了获得卡包的许可 我想从用户那里获取 ID 然后我创建了一个窗口来从用户那里获取 RegisterKey 这是我的GetReg
  • 求所有连续子数组最大差值之和(S)的最佳方法

    给定一个包含 n 个元素的数组 d 0 d 1 d n 1 计算所有连续子数组的最大差值的和 S 形式上 S 总和 max d l r 最小值 d l r 0 Input 4 1 3 2 4 Output 12 解释 l 0 r 0 数组
  • python绘制多个直方图

    我有一个包含 30 个变量的数据框 X v1 v2 v30 and col name v1 v2 v30 对于每个变量 我想绘制直方图以了解变量分布 但是 写代码逐一绘制太手动了 我可以用for循环之类的东西一次性绘制30个直方图吗 例如
  • Python 3.1.3 打开 mbox 文件,与 python 2.x 相比真的慢吗?

    我尝试在 python 3 1 3 中使用邮箱模块打开 mbox 文件 里面只有3封邮件 只有27k大 但是 当阅读邮件时 我的 CPU 使用 100 大约 2 3 分钟 直到它完成任务且没有错误 我用 python 2 7 1 尝试了同样
  • 在 Android 上实时更改曲目的播放速率

    我想知道是否有人知道一个可以实时更改曲目播放速率的库 我的想法是加载曲目并将其播放速率更改为一半或两倍 首先 我尝试使用 MusicPlayer 但根本不可能 然后我尝试使用 SoundPool 问题是 使用 SoundPool 一旦加载曲
  • 如何复制包含“\0”字符的数据

    我正在尝试复制包含 0 的数据 我正在使用 C 当研究结果是否定的时 我决定编写自己的函数来将数据从一个 char 复制到另一个 char 但它没有返回想要的结果 我的尝试如下 include
  • Laravel 急切加载与嵌套关系

    我知道有人问过这个问题 但我的情况有所不同 我定义了与评论模型关系的帖子模型 Post Model public function comments return this gt hasMany comment 和评论模型 每个评论属于一个
  • 在Python中查找列表中最长和最短的列表[重复]

    这个问题在这里已经有答案了 我需要打印列表中具有最小和最大项目数的列表 例如 如果我有 total list 1 2 3 1 2 3 4 1 2 3 4 5 我需要返回具有最小和最大长度的列表 我该怎么做 输出可能类似于 total lis
  • WndProc 中未捕获表单 WM_KEYDOWN 和 WM_KEYUP 消息

    不捕获表单 keydown 和 keyup 消息 public partial class Form1 Form const int WM KEYDOWN 0x100 const int WM KEYUP 0x101 protected o
  • Firestore:查询与搜索词匹配或相似的名称

    我有一个用户列表 其姓名位于 Firestore 数据库中 我想要实现的是让用户能够搜索和找到其他用户 我的问题是 Query query db collection users whereEqualTo name searchTerm F
  • 检查电池电量 iOS Swift [关闭]

    Closed 这个问题需要调试细节 目前不接受答案 我刚刚开始使用 Swift 一直在寻找一种检查电池电量的方法 我发现这个资源并一直在尝试它 但由于某种原因似乎无法让它工作 我不太确定如何解决这个问题 有任何想法吗 Xcode 11 Sw
  • 无法实例化活动 - android studio

    我正在 android studio 中制作一个应用程序 当启动我的一项活动时 应用程序崩溃并说它无法实例化该活动 我检查了清单文件 活动名称带有红色下划线 上面写着 X 不是具体类 验证 Android XML 文件中的资源 任何帮助将不
  • 空手道:如何使用 sudo 实现 Linux 使用的 --no-sandbox 标头

    我想在 jenkins 中为 UI 测试自动化设置一个无头 chrome 驱动程序 但要运行测试命令 sudo E java jar karate 0 9 3 jar karate GUI feature 我必须以 root 身份运行 并且