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

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: Renamed hook and updated doc strings. 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 ExecuteJavascriptInOOBEWebUI(self, js, frame_xpath=''):
3217 """Executes a script in the specified frame of the OOBE WebUI.
3218
3219 By default, execute the script in the top frame of the OOBE window. This
3220 also works for all OOBE pages, including the enterprise enrollment
3221 screen and login page. The invoked javascript function must send a result
3222 back via the domAutomationController.send function, or this function will
3223 never return.
3224
3225 Args:
3226 js: Script to be executed.
3227 frame_xpath: XPath of the frame to execute the script. Default is no
3228 frame. Example: '//frames[1]'
3229
3230 Returns:
3231 A value that was sent back via the domAutomationController.send method.
3232
3233 Raises:
3234 pyauto_errors.JSONInterfaceError if the automation call returns an error.
3235 """
3236 cmd_dict = {
3237 'command': 'ExecuteJavascriptInOOBEWebUI',
3238
3239 'javascript': js,
3240 'frame_xpath': frame_xpath,
3241 }
3242 result = self._GetResultFromJSONRequest(cmd_dict, windex=None)['result']
3243 # Wrap result in an array before deserializing because valid JSON has an
3244 # array or an object as the root.
3245 return json.loads('[' + result + ']')[0]
3246
3247
3216 def GetDOMValue(self, expr, tab_index=0, windex=0, frame_xpath=''): 3248 def GetDOMValue(self, expr, tab_index=0, windex=0, frame_xpath=''):
3217 """Executes a Javascript expression and returns the value. 3249 """Executes a Javascript expression and returns the value.
3218 3250
3219 This is a wrapper for ExecuteJavascript, eliminating the need to 3251 This is a wrapper for ExecuteJavascript, eliminating the need to
3220 explicitly call domAutomationController.send function. 3252 explicitly call domAutomationController.send function.
3221 3253
3222 Args: 3254 Args:
3223 expr: expression value to be returned. 3255 expr: expression value to be returned.
3224 tab_index: index of the tab. 3256 tab_index: index of the tab.
3225 windex: index of the window. 3257 windex: index of the window.
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 successful = result.wasSuccessful() 5440 successful = result.wasSuccessful()
5409 if not successful: 5441 if not successful:
5410 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 5442 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
5411 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 5443 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
5412 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 5444 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
5413 sys.exit(not successful) 5445 sys.exit(not successful)
5414 5446
5415 5447
5416 if __name__ == '__main__': 5448 if __name__ == '__main__':
5417 Main() 5449 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