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

Side by Side Diff: tools/telemetry/telemetry/click_element_action.py

Issue 12278015: [Telemetry] Reorganize everything. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-add shebangs. Created 7 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4 from telemetry import inspector_runtime
5 from telemetry import page as page_module
6 from telemetry import page_action
7 from telemetry import util
8
9 class ClickElementAction(page_action.PageAction):
10 def __init__(self, attributes=None):
11 super(ClickElementAction, self).__init__(attributes)
12
13 def RunAction(self, page, tab, previous_action):
14 def DoClick():
15 assert hasattr(self, 'selector') or hasattr(self, 'text')
16 if hasattr(self, 'selector'):
17 code = 'document.querySelector(\'' + self.selector + '\').click();'
18 try:
19 tab.ExecuteJavaScript(code)
20 except inspector_runtime.EvaluateException:
21 raise page_action.PageActionFailed(
22 'Cannot find element with selector ' + self.selector)
23 else:
24 callback_code = 'function(element) { element.click(); }'
25 try:
26 util.FindElementAndPerformAction(tab, self.text, callback_code)
27 except inspector_runtime.EvaluateException:
28 raise page_action.PageActionFailed(
29 'Cannot find element with text ' + self.text)
30
31 if hasattr(self, 'wait_for_navigate'):
32 tab.PerformActionAndWaitForNavigate(DoClick)
33 elif hasattr(self, 'wait_for_href_change'):
34 old_url = tab.EvaluateJavaScript('document.location.href')
35 DoClick()
36 util.WaitFor(lambda: tab.EvaluateJavaScript(
37 'document.location.href') != old_url, 60)
38 else:
39 DoClick()
40
41 page_module.Page.WaitForPageToLoad(self, tab, 60)
42 tab.WaitForDocumentReadyStateToBeInteractiveOrBetter()
OLDNEW
« no previous file with comments | « tools/telemetry/telemetry/chromeos_login_ext/manifest.json ('k') | tools/telemetry/telemetry/click_element_action_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698