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

Unified 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: Ready for review. Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/pyautolib/pyauto.py
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py
index 683b8a4c75effebee230a7bde1a33ceafed2d139..1f31bec59ffa7c32e80ffa871159097d8c71d8fc 100755
--- a/chrome/test/pyautolib/pyauto.py
+++ b/chrome/test/pyautolib/pyauto.py
@@ -3213,6 +3213,36 @@ class PyUITest(pyautolib.PyUITestBase, unittest.TestCase):
json_string = '[' + result + ']'
return json.loads(json_string)[0]
+ def ExecuteJavascriptInLogin(self, js, frame_xpath=''):
Nirnimesh 2012/04/27 22:46:38 I recommend appending 'WebUI' to the name
craigdh 2012/04/27 23:29:50 Done.
+ """Executes a script in the specified frame of a tab.
Nirnimesh 2012/04/27 22:46:38 fix
craigdh 2012/04/27 23:29:50 Done.
+
+ By default, execute the script in the top frame of the login window. This
+ also works for other pre-login pages, including the enterprise enrollment
+ screen. The invoked javascript function must send a result back via the
+ domAutomationController.send function, or this function will never return.
+
+ Args:
+ js: Script to be executed.
+ frame_xpath: XPath of the frame to execute the script. Default is no
+ frame. Example: '//frames[1]'
+
+ Returns:
+ A value that was sent back via the domAutomationController.send method.
+
+ Raises:
+ pyauto_errors.JSONInterfaceError if the automation call returns an error.
+ """
+ cmd_dict = {
+ 'command': 'ExecuteJavascriptInLogin',
+ 'javascript': js,
+ 'frame_xpath': frame_xpath,
+ }
+ result = self._GetResultFromJSONRequest(cmd_dict, windex=None)['result']
+ # Wrap result in an array before deserializing because valid JSON has an
+ # array or an object as the root.
+ return json.loads('[' + result + ']')[0]
+
+
def GetDOMValue(self, expr, tab_index=0, windex=0, frame_xpath=''):
"""Executes a Javascript expression and returns the value.

Powered by Google App Engine
This is Rietveld 408576698