From 7ad1cac85e099546dc5ff4424d5c37cbc0fe473e Mon Sep 17 00:00:00 2001 From: "dpranke@chromium.org" Date: Thu, 5 Aug 2010 01:01:50 +0000 Subject: Add ExecuteJavascript() method to PyUITestBase This allows us to evaluate JavaScript expressions in the renderer and read values out of the DOM of the page, which is useful for testing things like the PasswordManager. R=nirimesh@chromium.org, jrg@chromium.org, alyssad@chromium.org TEST=chrome/test/functional/test_execute_javascript.py BUG=none Review URL: http://codereview.chromium.org/3012039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55013 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/functional/execute_javascript.py | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 chrome/test/functional/execute_javascript.py (limited to 'chrome/test/functional/execute_javascript.py') diff --git a/chrome/test/functional/execute_javascript.py b/chrome/test/functional/execute_javascript.py new file mode 100644 index 0000000..f999f3a --- /dev/null +++ b/chrome/test/functional/execute_javascript.py @@ -0,0 +1,37 @@ +#!/usr/bin/python +# Copyright (c) 2010 The Chromium Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. + +import os +import sys +import unittest + +import pyauto_functional +from pyauto import PyUITest + + +class ExecuteJavascriptTest(PyUITest): + + def testExecuteJavascript(self): + path = os.path.join(self.DataDir(), "frame_dom_access", + "frame_dom_access.html") + + self.NavigateToURL(self.GetFileURLForPath(path)) + + v = self.ExecuteJavascript("window.domAutomationController.send(" + + "document.getElementById('myinput').nodeName)") + self.assertEqual(v, "INPUT") + + def testGetDOMValue(self): + path = os.path.join(self.DataDir(), "frame_dom_access", + "frame_dom_access.html") + + self.NavigateToURL(self.GetFileURLForPath(path)) + + v = self.GetDOMValue("document.getElementById('myinput').nodeName") + self.assertEqual(v, "INPUT") + + +if __name__ == '__main__': + pyauto_functional.Main() -- cgit v1.1