Changing default path for Chrome executable for karate-chrome

本小妞迷上赌 提交于 2021-02-05 08:41:09

问题


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.

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.

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

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


回答1:


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.

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.

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.

EDIT: 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

It should be something like this:

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


来源:https://stackoverflow.com/questions/65253018/changing-default-path-for-chrome-executable-for-karate-chrome

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!