1

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.

Leo P
  • 33
  • 2

1 Answers1

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

enter image description here

It should be something like this:

Chrome.start("/opt/blah/chrome");
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • Thanks Peter for a prompt reply. Yes docker would indeed be an overkill as I need the browser just to take a screenshot. For now, I am already sending the html along with other artifacts as a zipped file through Jenkins. The email sent through jenkins is routed through the custom html email template. Moreover the stakeholders tend to ignore the umpteen files within the zip file and hence the thought of including the screenshot in email body to make it more visible. So was wondering if there could be or already is a provision to change the default location of the Chrome executable. Thanks again – Leo P Dec 11 '20 at 15:45
  • @LeoP what we can try to do in the next version is provide a "lite" version of the HTML report that is easy to attach to e-mails. but do note that you can change the location of where the `Chrome.start()` looks for the executable see my edit to the answer – Peter Thomas Dec 11 '20 at 15:50