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

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: need to push again to make sure rietveld didn't screw up 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
« no previous file with comments | « 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 b96b7d70f5ac6d6be402dd090a6b195c886c3661..223ce51e6712a5bd0c094defbd0418e16e60ecdf 100644
--- a/chrome/test/webdriver/session.cc
+++ b/chrome/test/webdriver/session.cc
@@ -14,6 +14,7 @@
#include "base/json/json_writer.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
+#include "base/memory/scoped_temp_dir.h"
#include "base/message_loop_proxy.h"
#include "base/process.h"
#include "base/process_util.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);
}
@@ -981,4 +983,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::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() const {
+ return speed_;
+}
+
+void Session::set_speed(Speed speed) {
+ speed_ = speed;
+}
+
} // namespace webdriver
« no previous file with comments | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698