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

Unified Diff: chrome/test/webdriver/session.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/session.cc
===================================================================
--- chrome/test/webdriver/session.cc (revision 79141)
+++ chrome/test/webdriver/session.cc (working copy)
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/test/webdriver/session_manager.h"
+#include "chrome/test/webdriver/session.h"
#include <sstream>
#include <vector>
@@ -468,6 +468,29 @@
return SwitchToFrameWithJavaScriptLocatedFrame(script, &args);
}
+ErrorCode Session::SwitchToFrameWithElement(const WebElementId& element) {
+ // TODO(jleyba): Extract this, and the other frame switch methods to an atom.
+ std::string script =
+ "var element = arguments[0];"
+ "console.info('Attempting to switch to ' + element);"
+ "if (element.nodeType != 1 || !/^i?frame$/i.test(element.tagName)) {"
+ " console.info('Element is not a frame: ' + element + "
+ "' {nodeType:' + element.nodeType + ',tagName:' + element.tagName + '}');"
+ " return null;"
+ "}"
+ "for (var i = 0; i < window.frames.length; i++) {"
+ " if (element.contentWindow == window.frames[i]) {"
+ " return '(//iframe|//frame)[' + (i + 1) + ']';"
+ " }"
+ "}"
+ "console.info('Frame is not connected to this DOM tree');"
+ "return null;";
+
+ ListValue args;
+ args.Append(element.ToValue());
+ return SwitchToFrameWithJavaScriptLocatedFrame(script, &args);
+}
+
void Session::SwitchToTopFrame() {
current_target_.frame_path = FramePath();
}
« chrome/test/webdriver/chromedriver_tests.py ('K') | « chrome/test/webdriver/session.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698