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

Unified Diff: tools/chrome_remote_control/chrome_remote_control/interaction_clickLink.js

Issue 11369075: Chrome remote control multipage tests: Add interactions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more robust dispatching (allow splitting interactions to separate files) Created 8 years, 1 month 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: tools/chrome_remote_control/chrome_remote_control/interaction_clickLink.js
diff --git a/tools/chrome_remote_control/chrome_remote_control/interaction_clickLink.js b/tools/chrome_remote_control/chrome_remote_control/interaction_clickLink.js
new file mode 100644
index 0000000000000000000000000000000000000000..288f25bb7275b1024d9b12d8b0975f7839d105fc
--- /dev/null
+++ b/tools/chrome_remote_control/chrome_remote_control/interaction_clickLink.js
@@ -0,0 +1,33 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
nduca 2012/11/06 05:03:27 non normative file name. click_link_interaction.js
marja 2012/11/06 16:01:21 There is no .py; test_helper_interaction.py (which
+// found in the LICENSE file.
+
+// Inject this script on any page to use test helpers, e.g., click a link which
+// matches a given text.
+
+(function() {
+ function findElementWithText(element, text) {
+ if (element.innerHTML == text) {
+ return element;
+ }
+ for (var i in element.childNodes) {
+ var foundElement = findElementWithText(element.childNodes[i], text);
+ if (foundElement) {
+ return foundElement;
+ }
+ }
+ return null;
+ }
+
+ function clickLink(interaction_json) {
+ var interaction = JSON.parse(interaction_json);
+ var element = findElementWithText(document, interaction["link_text"]);
+ if (element) {
+ element.click();
+ return true;
+ }
+ return false;
+ }
+
+ window.__clickLink = clickLink;
+})();

Powered by Google App Engine
This is Rietveld 408576698