空手道:如何使用sudo为Linux使用实现--no-sandbox标头 [英] Karate: How to implement --no-sandbox header for linux usage with sudo

查看:343
本文介绍了空手道:如何使用sudo为Linux使用实现--no-sandbox标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to setup a headless chrome driver for UI Test Automation in jenkins.

但是要运行测试命令

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

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

I have to run as root and it requires --no-sandbox, which, if I'm not wrong, it's still not supported in v0.9.3.

如果可能的话,如何添加--no-sandbox选项?

If possible, how can I include --no-sandbox option?

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

I checked https://intuit.github.io/karate/karate-core/ and there is no --no-sandbox option.

我的功能配置:

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命令及其结果

The linux command and it's results

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-随时打开票证并帮助我们提供一些链接,说明为什么需要这样做,做什么等等.

I guess you do know that the UI automation pieces are still experimental and yes I don't think we support --no-sandbox - feel free to open a ticket and help us with some links to why this is needed, what it does etc.

建议的解决方法是,您可以将批处理文件作为executable密钥传递给 configure driver 调用.然后,在此批处理文件中,您可以使用所需的任何自定义参数或参数来调用chromedriver可执行文件.

A suggested workaround is you can pass a batch file as the executable key to the configure driver call. In this batch file you can then call the chromedriver executable with whatever custom parameters or arguments you need.

请告诉我们是否可行.对我来说,听起来还需要一种传递任何自定义标志的方法,请将其添加到您的功能请求中.

Do let us know if that works. It also sounds to me that a way to pass any custom flags is a needed feature, do add this to your feature request.

对于那些将来登陆这里的人,我不确定100%,但是也许这里的信息会有所帮助:

for those landing here in future, I'm not 100% sure, but maybe the info here will help: https://github.com/intuit/karate/issues/1134#issuecomment-638990087

这篇关于空手道:如何使用sudo为Linux使用实现--no-sandbox标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆