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

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 10257015: Added a new automation hook ExecuteJavascriptInOOBEWebUI() to execute javascript prior to login on… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed reviewer comments. Created 8 years, 7 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
« no previous file with comments | « chrome/test/functional/chromeos_login.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """PyAuto: Python Interface to Chromium's Automation Proxy. 6 """PyAuto: Python Interface to Chromium's Automation Proxy.
7 7
8 PyAuto uses swig to expose Automation Proxy interfaces to Python. 8 PyAuto uses swig to expose Automation Proxy interfaces to Python.
9 For complete documentation on the functionality available, 9 For complete documentation on the functionality available,
10 run pydoc on this file. 10 run pydoc on this file.
(...skipping 3195 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 'javascript' : js, 3206 'javascript' : js,
3207 'view' : view, 3207 'view' : view,
3208 'frame_xpath' : frame_xpath, 3208 'frame_xpath' : frame_xpath,
3209 } 3209 }
3210 result = self._GetResultFromJSONRequest(cmd_dict, windex=None)['result'] 3210 result = self._GetResultFromJSONRequest(cmd_dict, windex=None)['result']
3211 # Wrap result in an array before deserializing because valid JSON has an 3211 # Wrap result in an array before deserializing because valid JSON has an
3212 # array or an object as the root. 3212 # array or an object as the root.
3213 json_string = '[' + result + ']' 3213 json_string = '[' + result + ']'
3214 return json.loads(json_string)[0] 3214 return json.loads(json_string)[0]
3215 3215
3216 def ExecuteJavascriptInLoginWebUI(self, js, frame_xpath=''):
Nirnimesh 2012/04/30 18:57:07 Login -> OOBE
3217 """Executes a script in the specified frame of a pre-login WebUI.
Nirnimesh 2012/04/30 18:57:07 pre-login -> OOBE
3218
3219 By default, execute the script in the top frame of the login window. This
Nirnimesh 2012/04/30 18:57:07 Remove reference to 'login'. Mention: Can be used
3220 also works for other pre-login pages, including the enterprise enrollment
3221 screen. The invoked javascript function must send a result back via the
3222 domAutomationController.send function, or this function will never return.
3223
3224 Args:
3225 js: Script to be executed.
3226 frame_xpath: XPath of the frame to execute the script. Default is no
3227 frame. Example: '//frames[1]'
3228
3229 Returns:
3230 A value that was sent back via the domAutomationController.send method.
3231
3232 Raises:
3233 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3234 """
3235 cmd_dict = {
3236 'command': 'ExecuteJavascriptInLoginWebUI',
3237 'javascript': js,
3238 'frame_xpath': frame_xpath,
3239 }
3240 result = self._GetResultFromJSONRequest(cmd_dict, windex=None)['result']
3241 # Wrap result in an array before deserializing because valid JSON has an
3242 # array or an object as the root.
3243 return json.loads('[' + result + ']')[0]
3244
3245
3216 def GetDOMValue(self, expr, tab_index=0, windex=0, frame_xpath=''): 3246 def GetDOMValue(self, expr, tab_index=0, windex=0, frame_xpath=''):
3217 """Executes a Javascript expression and returns the value. 3247 """Executes a Javascript expression and returns the value.
3218 3248
3219 This is a wrapper for ExecuteJavascript, eliminating the need to 3249 This is a wrapper for ExecuteJavascript, eliminating the need to
3220 explicitly call domAutomationController.send function. 3250 explicitly call domAutomationController.send function.
3221 3251
3222 Args: 3252 Args:
3223 expr: expression value to be returned. 3253 expr: expression value to be returned.
3224 tab_index: index of the tab. 3254 tab_index: index of the tab.
3225 windex: index of the window. 3255 windex: index of the window.
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 successful = result.wasSuccessful() 5438 successful = result.wasSuccessful()
5409 if not successful: 5439 if not successful:
5410 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5440 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5411 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5441 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5412 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5442 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5413 sys.exit(not successful) 5443 sys.exit(not successful)
5414 5444
5415 5445
5416 if __name__ == '__main__': 5446 if __name__ == '__main__':
5417 Main() 5447 Main()
OLDNEW
« no previous file with comments | « chrome/test/functional/chromeos_login.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698