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

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

Issue 10824237: Fix a bug in pyauto.py where JavascriptRuntimeError is raised but not imported. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | « no previous file | 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 print >>sys.stderr, '*\n* Perhaps use "python2.5", not "python" ?\n*' 77 print >>sys.stderr, '*\n* Perhaps use "python2.5", not "python" ?\n*'
78 raise 78 raise
79 79
80 # Should go after sys.path is set appropriately 80 # Should go after sys.path is set appropriately
81 import bookmark_model 81 import bookmark_model
82 import download_info 82 import download_info
83 import history_info 83 import history_info
84 import omnibox_info 84 import omnibox_info
85 import plugins_info 85 import plugins_info
86 import prefs_info 86 import prefs_info
87 from pyauto_errors import JavascriptRuntimeError
87 from pyauto_errors import JSONInterfaceError 88 from pyauto_errors import JSONInterfaceError
88 from pyauto_errors import NTPThumbnailNotShownError 89 from pyauto_errors import NTPThumbnailNotShownError
89 import pyauto_utils 90 import pyauto_utils
90 import simplejson as json # found in third_party 91 import simplejson as json # found in third_party
91 92
92 _CHROME_DRIVER_FACTORY = None 93 _CHROME_DRIVER_FACTORY = None
93 _HTTP_SERVER = None 94 _HTTP_SERVER = None
94 _REMOTE_PROXY = None 95 _REMOTE_PROXY = None
95 _OPTIONS = None 96 _OPTIONS = None
96 _BROWSER_PID = None 97 _BROWSER_PID = None
(...skipping 3604 matching lines...) Expand 10 before | Expand all | Expand 10 after
3701 js = ('(' + f.read() + ')(%d, %d, "%s", "%s", "%s", %s);' % 3702 js = ('(' + f.read() + ')(%d, %d, "%s", "%s", "%s", %s);' %
3702 (automation_id, observer_id, mutation_type, 3703 (automation_id, observer_id, mutation_type,
3703 xpath.replace('"', r'\"'), attribute, expected_string)) 3704 xpath.replace('"', r'\"'), attribute, expected_string))
3704 exec_js = exec_js or PyUITest.ExecuteJavascript 3705 exec_js = exec_js or PyUITest.ExecuteJavascript
3705 try: 3706 try:
3706 jsreturn = exec_js(self, js, **kwargs) 3707 jsreturn = exec_js(self, js, **kwargs)
3707 except JSONInterfaceError: 3708 except JSONInterfaceError:
3708 raise JSONInterfaceError('Failed to inject DOM mutation observer.') 3709 raise JSONInterfaceError('Failed to inject DOM mutation observer.')
3709 if jsreturn != 'success': 3710 if jsreturn != 'success':
3710 self.RemoveEventObserver(observer_id) 3711 self.RemoveEventObserver(observer_id)
3711 raise pyauto_errors.JavascriptRuntimeError(jsreturn) 3712 raise JavascriptRuntimeError(jsreturn)
3712 return observer_id 3713 return observer_id
3713 3714
3714 def WaitForDomNode(self, xpath, attribute='textContent', 3715 def WaitForDomNode(self, xpath, attribute='textContent',
3715 expected_value=None, exec_js=None, timeout=-1, 3716 expected_value=None, exec_js=None, timeout=-1,
3716 msg='Expected DOM node failed to appear.', **kwargs): 3717 msg='Expected DOM node failed to appear.', **kwargs):
3717 """Waits until a node specified by an xpath exists in the DOM. 3718 """Waits until a node specified by an xpath exists in the DOM.
3718 3719
3719 NOTE: This does NOT poll. It returns as soon as the node appears, or 3720 NOTE: This does NOT poll. It returns as soon as the node appears, or
3720 immediately if the node already exists. 3721 immediately if the node already exists.
3721 3722
(...skipping 2937 matching lines...) Expand 10 before | Expand all | Expand 10 after
6659 successful = result.wasSuccessful() 6660 successful = result.wasSuccessful()
6660 if not successful: 6661 if not successful:
6661 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename) 6662 pyauto_tests_file = os.path.join(self.TestsDir(), self._tests_filename)
6662 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \ 6663 print >>sys.stderr, 'Tests can be disabled by editing %s. ' \
6663 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL) 6664 'Ref: %s' % (pyauto_tests_file, _PYAUTO_DOC_URL)
6664 sys.exit(not successful) 6665 sys.exit(not successful)
6665 6666
6666 6667
6667 if __name__ == '__main__': 6668 if __name__ == '__main__':
6668 Main() 6669 Main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698