Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5797)

Unified Diff: chrome/test/webdriver/commands/response.h

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: for review Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/webdriver/commands/response.h
diff --git a/chrome/test/webdriver/commands/response.h b/chrome/test/webdriver/commands/response.h
index b77404d2260d67f3cec7f43550806640770b6e7e..8486b1f82727a807cba511cea2dd6ce900bbb4e2 100644
--- a/chrome/test/webdriver/commands/response.h
+++ b/chrome/test/webdriver/commands/response.h
@@ -19,6 +19,16 @@ namespace webdriver {
response->SetError(err, msg, __FILE__, __LINE__); \
LOG(ERROR) << msg
+// Use this macro for errors in which a screenshot can be taken and
+// sent back to the client. A proper stack trace will also be included.
+#define SET_WEBDRIVER_SCREENSHOT_ERROR(response, session, msg, err) { \
+ LOG(ERROR) << msg; \
+ std::string __screenshot__; \
+ session->ScreenshotAsBase64(&__screenshot__); \
+ response->SetError(err, msg, __FILE__, __LINE__); \
+ response->SetScreenshot(__screenshot__); \
+}
+
// A simple class that encapsulates the information describing the response to
// a |Command|. In Webdriver all responses must be sent back as a JSON value,
// conforming to the spec found at:
@@ -52,11 +62,16 @@ class Response {
// This object assumes ownership of |value|.
void SetField(const std::string& key, Value* value);
+ // Sets the screenshot to return to the client for debugging. The file must
+ // be a base64 encoded PNG file.
+ void SetScreenshot(const std::string& screenshot);
+
// Returns this response as a JSON string.
std::string ToJSON() const;
private:
DictionaryValue data_;
+ std::string screenshot_;
DISALLOW_COPY_AND_ASSIGN(Response);
};

Powered by Google App Engine
This is Rietveld 408576698