Chromium Code Reviews| 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; |
| +})(); |