Feature Reqest - base64 encoded embedded images #264

Twistedpear opened this Issue Feb 8, 2012 · 2 comments


None yet

2 participants

Hi All,

One of the things I really like about Webdriver is the ability to embed a base64 image into a Cucumber html report, rather than rely on an image to be present in a particular location ad infinata...

Was wondering if it would be possible to get a similar feature in capybara-webdriver? :)



jferris commented Feb 8, 2012

Hey Rob - sounds like a decent feature. Please submit a pull request if you're interested.

@jferris jferris closed this Feb 8, 2012

After having a look through the code, it looks as if the PNG image is generated by QT itself.

You can convert the PNG to Base64 post screenshotting using the following code:

img_name = "#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}.png"
img = page.driver.render img_name
encoded_img = Base64.encode64(File.read(img_name))
File.delete img_name
#embedding the base64 image in a cucumber html report
embed("data:image/png;base64,#{encoded_img}", 'image/png')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment