Index: chrome/test/pyautolib/pyauto.py |
diff --git a/chrome/test/pyautolib/pyauto.py b/chrome/test/pyautolib/pyauto.py |
index 683b8a4c75effebee230a7bde1a33ceafed2d139..78a10a94d56cee1cbe7cac73e6dbdfa2957c9c8f 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 ExecuteJavascriptInLoginWebUI(self, js, frame_xpath=''): |
+ """Executes a script in the specified frame of a pre-login WebUI. |
+ |
+ 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': 'ExecuteJavascriptInLoginWebUI', |
+ '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. |