Issue Details (XML | Word | Printable)

Key: SRC-381
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Andras Hatvani
Reporter: Rob Dupuis
Votes: 0
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Selenium Remote Control

Enhance capture screenshot to stream screenshot to client

Created: 07/Nov/07 08:41 AM   Updated: 17/Dec/09 06:51 AM   Resolved: 27/Nov/08 03:45 PM
Component/s: Server
Affects Version/s: None
Fix Version/s: 1.0 beta 2

File Attachments: 1. Text File captureScreenshotToString-corechanges.patch (1.0 kB) 27/May/08 08:53 PM - Erik Beans
2. Text File captureScreenshotToString-serverchanges.patch (3 kB) 28/May/08 03:01 PM - Jason Huggins

Issue Links:
Relationship
 


 Description  « Hide

When using selenium rc with selenium grid it's inconvenient to have to save screenshots locally on the grid members for a number of reasons.

Could the capture screenshot method somehow stream the screenshot down to the client. Not sure if selenium rc supports sending binary results back to the client; if not, it could be mime encoded. In my case this would allow the test executing to decide where to store the image (in my case I want to pulish to a cruise artifact dir).



Sort Order: Ascending order - Click to sort in descending order
Rob Dupuis added a comment - 07/Nov/07 08:43 AM

Err when I said mime encoded I meant base 64 encoded. Brain wrong.


Rob Dupuis added a comment - 02/Jan/08 12:47 PM

This should be closed in favour of SRC-395 which includes a patch.


Erik Beans added a comment - 27/May/08 08:53 PM

Here is a patch that modifies selenium to add an API method for capturing a screenshot and returning it as a string which is a base64 encoded png file. This uses the Robot class to capture the current screen. The API method is called captureScreenshotToString.


Jason Huggins added a comment - 28/May/08 03:06 PM

I closed SRC-395 as a duplicate of this issue.

My reasons:
1) This issue came first.
2) The implementation behind this issue is instantly cross-language, returning a Base64 encoded string version of the screenshot, instead of a Java-specific BufferedImage.

Read my comments in SRC-395 for more of my commentary. But basically, the good bits in SRC-395, should get reworked as enhancements to this patch. That way, all supported client libraries will get the feature at the same time.


Jason Huggins added a comment - 28/May/08 07:29 PM

Code has been commited to subversion for this patch:
Core: svn revision 2084
RC: svn revision 2306

Remaining task is add some documentation to the wiki on how to use the new feature. Happy captureScreenshottingToFile, everyone!


Eric added a comment - 25/Nov/08 08:28 PM

It says this is fixed in beta 1 but I get an error when calling the command. I tried the nightly snapshot and that is hosed. when trying to run it.

How can I add just this functionality to beta 1 (i am not a java dev, perl/php, never compiled a jar)


Andras Hatvani added a comment - 27/Nov/08 03:44 PM

Changed fix version until release of 1.0 only part of the nightly builds available at http://release.openqa.org/cgi-bin/selenium-remote-control-redirect.zip.


Andras Hatvani added a comment - 27/Nov/08 03:45 PM

Resolved by Erik Beans, patch submitted by Jason Huggins
Core: svn revision 2084
RC: svn revision 2306


Evan Leonard added a comment - 21/Sep/09 03:04 PM

Would someone post a code snippet showing how to save the base64 to a file? Be sure to include this in the updated docs too. Thanks for this btw!


Robert Elliot added a comment - 17/Dec/09 06:51 AM

In Java:

import java.io.File
import java.io.ByteArrayInputStream
import java.awt.image.BufferedImage
import javax.imageio.ImageIO
import com.thoughtworks.selenium.DefaultSelenium
import org.apache.commons.codec.binary.Base64

String screenshotString = selenium.captureEntirePageScreenshotToString("");
byte[] imageBytes = Base64.decodeBase64(screenshotString.getBytes("UTF-8"));
BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageBytes));
ImageIO.write(image, "png", new File("/home/me/screenshot.png");