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

Unified Diff: chrome/test/webdriver/session.cc

Issue 5572001: Send screenshots back to the client for debugging (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: added tests which compare against a reference md5 hash Created 9 years, 9 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
« chrome/test/webdriver/session.h ('K') | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/webdriver/session.cc
diff --git a/chrome/test/webdriver/session.cc b/chrome/test/webdriver/session.cc
index ebb7fae51ab67c7e07f8124585ccd6f4ba31935d..1472f3605c14d97cee2e555021c2a9a6d3e9773e 100644
--- a/chrome/test/webdriver/session.cc
+++ b/chrome/test/webdriver/session.cc
@@ -17,6 +17,7 @@
#include "base/process.h"
#include "base/process_util.h"
#include "base/scoped_ptr.h"
+#include "base/scoped_temp_dir.h"
#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
#include "base/string_split.h"
@@ -59,6 +60,7 @@ Session::Session()
: id_(GenerateRandomID()),
thread_(id_.c_str()),
implicit_wait_(0),
+ screenshot_on_error_(false),
current_target_(FrameId(0, FramePath())) {
SessionManager::GetInstance()->Add(this);
}
@@ -868,4 +870,56 @@ ErrorCode Session::GetLocationInViewHelper(const FrameId& frame_id,
return kSuccess;
}
+bool Session::GetScreenShot(std::string* png) {
+ bool success = false;
+ ScopedTempDir screenshots_dir;
+
+ // Create a temp directory for screenshots.
+ if (!screenshots_dir.CreateUniqueTempDir()) {
+ return false;
+ }
+
+ FilePath path = screenshots_dir.path().AppendASCII("screen");
+
+ RunSessionTask(NewRunnableMethod(
+ automation_.get(),
+ &Automation::CaptureEntirePageAsPNG,
+ current_target_.window_id,
+ path,
+ &success));
+
+ if (success) {
+ success = file_util::ReadFileToString(path, png);
+ }
+ return success;
+}
+
+void Session::set_screenshot_on_error(bool error) {
+ screenshot_on_error_ = error;
+}
+
+bool Session::get_screenshot_on_error() const {
+ return screenshot_on_error_;
+}
+
+const std::string& Session::id() const {
+ return id_;
+}
+
+int Session::implicit_wait() const {
+ return implicit_wait_;
+}
+
+void Session::set_implicit_wait(const int& timeout) {
+ implicit_wait_ = timeout > 0 ? timeout : 0;
+}
+
+Session::Speed Session::speed() {
+ return speed_;
+}
+
+void Session::set_speed(Speed speed) {
+ speed_ = speed;
+}
+
} // namespace webdriver
« chrome/test/webdriver/session.h ('K') | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698