credit: simpleicon.com |
In my current project I have to automate browser UI actions as part of regression test suite that is run using Jenkins. Watir-webdriver has a nice feature of taking and embedding screenshots into cucumber html test report. I am using screenshots when scenario fails in order to help myself in investigation what went wrong at the moment of failure.
Google search led me to Watirmelon post with the code example.
But in my context, that example did not work.
Example worked on my Mac development machine, but it did not work when I run test on Jenkins that is hosted on AMI linux instance.
#embed method documentation does not help a lot. So using Watirmelon example and testing by changing method arguments, I discovered that embedding screenshot in base64 format works both in AMI linux instance and my Mac development machine.
Here is gist:
Code that shows how to fully embed screenshot into report is from cucumber issue#651. I found this approach better because it does not clutter Jenkins job workspace with screenshot .png files.