更改适用于karate-chrome的Chrome可执行文件的默认路径 [英] Changing default path for Chrome executable for karate-chrome

查看:154
本文介绍了更改适用于karate-chrome的Chrome可执行文件的默认路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Karate框架进行API测试.作为CI工作的一部分,我们在测试执行结束时发送一封电子邮件,其中列出了测试结果的摘要.有必要包括"overview-feature.html"文件中测试执行计数的摘要.

I am using the Karate framework to do the API testing. As part of CI efforts, we send an email at the end of test execution listing the summary of test results. There is a need to include the screeshot of the test execution counts from 'overview-feature.html' file.

我是通过TestRunner.java文件来完成的-使用Chrome.start()启动了Chrome,然后使用它拍摄了屏幕截图.在Windows本地都可以很好地工作. 但是,在Unix框的CI服务器上执行时,默认位置(usr/bin/google-chrome)中不存在chrome可执行文件,因此localhost的连接失败.

I did so through the TestRunner.java file - launched Chrome using Chrome.start() and then using it to take screenshot. It all works well locally on Windows. However when executing on CI server which is a Unix box, the chrome executable is not present in the default location (usr/bin/google-chrome) and hence the connection for the localhost fails.

有没有一种方法可以更改chrome可执行文件的默认位置?

Is there a way we can change the default location of the chrome executable?

PS:抱歉,这太琐碎以至于无法问到.

PS: Apologies if this was too trivial to be asked.

推荐答案

是的,很难在CI上安装Chrome,请参考: https ://stackoverflow.com/a/62325328/143475 -请注意,CI框通常是无头的"浏览器甚至可能没有安装.

Yes Chrome on CI is hard to get right, refer: https://stackoverflow.com/a/62325328/143475 - note that CI boxes typically are "headless" a browser may not be even installed.

我认为对您来说最好的方法是将HTML压缩并发送.但是我真的认为您需要与一些CI专家一起工作,因为报告生成和电子邮件业务通常由詹金斯(Jenkins)等人完成.您正在做的事情肯定不是正常的或最佳实践.

I think the best thing for you is to ZIP the HTML and send it. But I really think you need to work with some CI experts, because the report generation and e-mailing business is normally done by things like Jenkins. What you are doing is certainly not normal or best-practice.

如果您真的想要,有一个空手道Docker容器可以为您提供适当的Chrome实例(

If you really want, there is a Karate Docker container that can give you a proper Chrome instance (see docs) but that is overkill for what you need.

Chrome Java API允许自定义可执行路径,这在文档中: https://github.com/intuit/karate/tree/master/karate-core#chrome-java-api

The Chrome Java API allows for customization of the executable path and this is in the docs: https://github.com/intuit/karate/tree/master/karate-core#chrome-java-api

应该是这样的:

Chrome.start("/opt/blah/chrome");

这篇关于更改适用于karate-chrome的Chrome可执行文件的默认路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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