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

Unified Diff: chrome/test/webdriver/commands/target_locator_commands.cc

Issue 6723004: ChromeDriver should be able to focus on a frame using its frame element, (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' 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
Index: chrome/test/webdriver/commands/target_locator_commands.cc
===================================================================
--- chrome/test/webdriver/commands/target_locator_commands.cc (revision 79141)
+++ chrome/test/webdriver/commands/target_locator_commands.cc (working copy)
@@ -9,6 +9,7 @@
#include "chrome/test/webdriver/commands/response.h"
#include "chrome/test/webdriver/error_codes.h"
#include "chrome/test/webdriver/session.h"
+#include "chrome/test/webdriver/web_element_id.h"
namespace webdriver {
@@ -108,6 +109,7 @@
void SwitchFrameCommand::ExecutePost(Response* const response) {
std::string id;
int index = 0;
+ WebElementId element;
if (GetStringParameter("id", &id)) {
ErrorCode code = session_->SwitchToFrameWithNameOrId(id);
if (code != kSuccess) {
@@ -120,6 +122,12 @@
SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code);
return;
}
+ } else if (GetWebElementParameter("id", &element)) {
+ ErrorCode code = session_->SwitchToFrameWithElement(element);
+ if (code != kSuccess) {
+ SET_WEBDRIVER_ERROR(response, "Could not switch to frame", code);
+ return;
+ }
} else if (IsNullParameter("id")) {
session_->SwitchToTopFrame();
} else {
@@ -130,6 +138,20 @@
response->SetStatus(kSuccess);
}
+bool SwitchFrameCommand::GetWebElementParameter(const std::string& key,
+ WebElementId* out) const {
+ DictionaryValue* value;
+ if (!GetDictionaryParameter(key, &value))
+ return false;
+
+ WebElementId id(value);
+ if (!id.is_valid())
+ return false;
+
+ *out = id;
+ return true;
+}
+
ActiveElementCommand::ActiveElementCommand(
const std::vector<std::string>& path_segments,
DictionaryValue* parameters)

Powered by Google App Engine
This is Rietveld 408576698