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

Side by Side Diff: tools/perf/page_sets/login_helpers/login_utils.py

Issue 2719853003: [Telemetry refactor] Drop "2" from method calls to JS API (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « tools/perf/page_sets/login_helpers/google_login.py ('k') | tools/perf/page_sets/maps.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import json 5 import json
6 import os 6 import os
7 7
8 8
9 DEFAULT_CREDENTIAL_PATH = os.path.join( 9 DEFAULT_CREDENTIAL_PATH = os.path.join(
10 os.path.dirname(__file__), os.path.pardir, 'data', 'credentials.json') 10 os.path.dirname(__file__), os.path.pardir, 'data', 'credentials.json')
(...skipping 27 matching lines...) Expand all
38 input_text: Text string to populate the input field with. 38 input_text: Text string to populate the input field with.
39 input_selector: The selector of the input element. 39 input_selector: The selector of the input element.
40 40
41 41
42 Raises: 42 Raises:
43 exceptions.TimeoutException: If waiting to find the element times out. 43 exceptions.TimeoutException: If waiting to find the element times out.
44 exceptions.Error: See ExecuteJavaScript() for a detailed list of 44 exceptions.Error: See ExecuteJavaScript() for a detailed list of
45 possible exceptions. 45 possible exceptions.
46 """ 46 """
47 action_runner.WaitForElement(selector=input_selector) 47 action_runner.WaitForElement(selector=input_selector)
48 action_runner.ExecuteJavaScript2( 48 action_runner.ExecuteJavaScript(
49 'document.querySelector({{ selector }}).value = {{ value }};', 49 'document.querySelector({{ selector }}).value = {{ value }};',
50 selector=input_selector, value=input_text) 50 selector=input_selector, value=input_text)
51 51
52 def InputForm(action_runner, input_text, input_id, form_id=None): 52 def InputForm(action_runner, input_text, input_id, form_id=None):
53 """Sets the text value of an input field in a form on the page. 53 """Sets the text value of an input field in a form on the page.
54 54
55 Waits until the input element exists on the page. Then executes JS to populate 55 Waits until the input element exists on the page. Then executes JS to populate
56 the value property of the element with |input_text|. 56 the value property of the element with |input_text|.
57 57
58 Args: 58 Args:
59 action_runner: ActionRunner instance to execute JS to populate form fields. 59 action_runner: ActionRunner instance to execute JS to populate form fields.
60 input_text: Text string to populate the input field with. 60 input_text: Text string to populate the input field with.
61 input_id: Id of the input field to populate. (type string). 61 input_id: Id of the input field to populate. (type string).
62 form_id: Optional form id string to identify |input_id| in querySelector. 62 form_id: Optional form id string to identify |input_id| in querySelector.
63 63
64 Raises: 64 Raises:
65 exceptions.TimeoutException: If waiting to find the element times out. 65 exceptions.TimeoutException: If waiting to find the element times out.
66 exceptions.Error: See ExecuteJavaScript() for a detailed list of 66 exceptions.Error: See ExecuteJavaScript() for a detailed list of
67 possible exceptions. 67 possible exceptions.
68 """ 68 """
69 if form_id and input_id: 69 if form_id and input_id:
70 element_selector = '#%s #%s' % (form_id, input_id) 70 element_selector = '#%s #%s' % (form_id, input_id)
71 elif input_id: 71 elif input_id:
72 element_selector = '#%s' % (input_id) 72 element_selector = '#%s' % (input_id)
73 else: 73 else:
74 raise ValueError("Input ID can not be None or empty.") 74 raise ValueError("Input ID can not be None or empty.")
75 InputWithSelector(action_runner, input_text, element_selector) 75 InputWithSelector(action_runner, input_text, element_selector)
OLDNEW
« no previous file with comments | « tools/perf/page_sets/login_helpers/google_login.py ('k') | tools/perf/page_sets/maps.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698