本文介绍了空手道是否支持CI环境中的无头测试(GitLab CI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们已经使用空手道框架实现了UI自动化。但我在尝试使用GitLab管道运行测试时面临挑战。
我使用的是Gradle构建工具,并在GitLab-ci.yaml中添加了一个简单的步骤,但构建每次都失败。以下是我尝试过的:在功能文件中添加了以下内容:* configure driver = { type: 'chrome', headless: true }
收到错误:
18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Opening connection {}->http://localhost:9222
18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.DefaultHttpClientConnectionOperator - Connecting to localhost/127.0.0.1:9222
18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.DefaultManagedHttpClientConnection - http-outgoing-8: Shutdown connection
18:10:39.056 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.execchain.MainClientExec - Connection discarded
18:10:39.057 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 8][route: {}->http://localhost:9222][total available: 0; route allocated: 0 of 5; total allocated: 0 of 10]
18:10:39.057 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9222 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 1 milliseconds for URL: http://localhost:9222
还尝试添加chromeDriver:* configure driver = { type: 'chromedriver', port: 9515, executable: 'chromedriver' }
。收到此错误:
18:19:01.541 [ForkJoinPool-1-worker-1] DEBUG org.apache.http.impl.conn.PoolingHttpClientConnectionManager - Connection released: [id: 0][route: {}->http://localhost:9515][total available: 0; route allocated: 0 of 5; total allocated: 0 of 10]
18:19:01.542 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1] failed: Connection refused (Connection refused), http call failed after 19 milliseconds for URL: http://localhost:9515/session
18:19:01.542 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - http request failed:
org.apache.http.conn.HttpHostConnectException: Connect to localhost:9515 [localhost/127.0.0.1] failed: Connection refused (Connection refused)
我希望在管道运行但到目前为止一切都不起作用时在特定环境上执行测试。
推荐答案
我们可以在.gitlab-ci.yml
的BEFORE_SCRIPT中添加安装Chrome和Chrome驱动的代码来解决前面提到的问题。
before_script:
- apt-get update && apt-get install -y --no-install-recommends google-chrome-stable
- wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip
- unzip chromedriver_linux64.zip
- mv chromedriver /usr/bin/chromedriver
- chown root:root /usr/bin/chromedriver
- chmod +x /usr/bin/chromedriver
这篇关于空手道是否支持CI环境中的无头测试(GitLab CI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!