OLD | NEW |
---|---|
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """PyAuto: Python Interface to Chromium's Automation Proxy. | 7 """PyAuto: Python Interface to Chromium's Automation Proxy. |
8 | 8 |
9 PyAuto uses swig to expose Automation Proxy interfaces to Python. | 9 PyAuto uses swig to expose Automation Proxy interfaces to Python. |
10 For complete documentation on the functionality available, | 10 For complete documentation on the functionality available, |
(...skipping 736 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
747 right key. It's useful to dump the preferences first to determine | 747 right key. It's useful to dump the preferences first to determine |
748 what type is expected for a particular preference path. | 748 what type is expected for a particular preference path. |
749 """ | 749 """ |
750 cmd_dict = { | 750 cmd_dict = { |
751 'command': 'SetPrefs', | 751 'command': 'SetPrefs', |
752 'path': path, | 752 'path': path, |
753 'value': value, | 753 'value': value, |
754 } | 754 } |
755 self._GetResultFromJSONRequest(cmd_dict) | 755 self._GetResultFromJSONRequest(cmd_dict) |
756 | 756 |
757 def SendWebkitKeyEvent(self, key_code, tab_index=0, windex=0): | |
dennis_jeffrey
2011/03/22 23:28:53
For consistency in naming variables, I recommend t
dyu1
2011/03/24 19:46:51
From the pydocs for pyauto most of the variables f
dennis_jeffrey
2011/03/25 16:56:14
Maybe we should change them all then >:-).
Just k
| |
758 """Send a webkit key event to the browser. | |
759 | |
760 Used to simulate key presses from the keyboard to interact with the browser. | |
761 | |
762 Args: | |
763 key_code: the hex value associated with the keypress (virtual key code). | |
764 windex: window index to work on. Defaults to 0 (first window) | |
765 tab_index: tab index to work on. Defaults to 0 (first tab) | |
dennis_jeffrey
2011/03/22 23:28:53
Swap the descriptions for the "windex" and "tab_in
dyu1
2011/03/24 19:46:51
Done.
| |
766 """ | |
767 cmd_dict = { | |
768 'command': 'SendWebkitKeyEvent', | |
769 'type': 0, # kRawKeyDownType | |
770 'text': '', | |
771 'isSystemKey': False, | |
772 'unmodifiedText': '', | |
773 'nativeKeyCode': 0, | |
774 'windowsKeyCode': key_code, | |
775 'modifiers': 0, | |
776 'windex': windex, | |
777 'tab_index': tab_index, | |
778 } | |
779 # Sending two requests, one each for "key down" and "key up". | |
780 self._GetResultFromJSONRequest(cmd_dict) | |
781 cmd_dict['type'] = 3 # kKeyUpType | |
782 self._GetResultFromJSONRequest(cmd_dict) | |
783 | |
757 def WaitForAllDownloadsToComplete(self, windex=0): | 784 def WaitForAllDownloadsToComplete(self, windex=0): |
758 """Wait for all downloads to complete. | 785 """Wait for all downloads to complete. |
759 | 786 |
760 Note: This method does not work for dangerous downloads. Use | 787 Note: This method does not work for dangerous downloads. Use |
761 WaitForGivenDownloadsToComplete (below) instead. | 788 WaitForGivenDownloadsToComplete (below) instead. |
762 """ | 789 """ |
763 cmd_dict = {'command': 'WaitForAllDownloadsToComplete'} | 790 cmd_dict = {'command': 'WaitForAllDownloadsToComplete'} |
764 self._GetResultFromJSONRequest(cmd_dict, windex=windex) | 791 self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
765 | 792 |
766 def WaitForDownloadToComplete(self, download_path, timeout=-1): | 793 def WaitForDownloadToComplete(self, download_path, timeout=-1): |
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2784 if self._options.verbose: | 2811 if self._options.verbose: |
2785 verbosity = 2 | 2812 verbosity = 2 |
2786 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 2813 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
2787 del loaded_tests # Need to destroy test cases before the suite | 2814 del loaded_tests # Need to destroy test cases before the suite |
2788 del pyauto_suite | 2815 del pyauto_suite |
2789 sys.exit(not result.wasSuccessful()) | 2816 sys.exit(not result.wasSuccessful()) |
2790 | 2817 |
2791 | 2818 |
2792 if __name__ == '__main__': | 2819 if __name__ == '__main__': |
2793 Main() | 2820 Main() |
OLD | NEW |