Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 | 2 |
| 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 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): | |
|
Ilya Sherman
2011/03/18 23:17:11
I'd be very surprised if this functionality is not
dyu1
2011/03/21 18:42:35
PyAuto was never meant to interact with the web UI
| |
| 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) | |
| 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 self._GetResultFromJSONRequest(cmd_dict) | |
| 780 cmd_dict['type'] = 3 # kKeyUpType | |
| 781 self._GetResultFromJSONRequest(cmd_dict) | |
| 782 | |
| 757 def WaitForAllDownloadsToComplete(self, windex=0): | 783 def WaitForAllDownloadsToComplete(self, windex=0): |
| 758 """Wait for all downloads to complete. | 784 """Wait for all downloads to complete. |
| 759 | 785 |
| 760 Note: This method does not work for dangerous downloads. Use | 786 Note: This method does not work for dangerous downloads. Use |
| 761 WaitForGivenDownloadsToComplete (below) instead. | 787 WaitForGivenDownloadsToComplete (below) instead. |
| 762 """ | 788 """ |
| 763 cmd_dict = {'command': 'WaitForAllDownloadsToComplete'} | 789 cmd_dict = {'command': 'WaitForAllDownloadsToComplete'} |
| 764 self._GetResultFromJSONRequest(cmd_dict, windex=windex) | 790 self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 765 | 791 |
| 766 def WaitForDownloadToComplete(self, download_path, timeout=-1): | 792 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: | 2810 if self._options.verbose: |
| 2785 verbosity = 2 | 2811 verbosity = 2 |
| 2786 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 2812 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
| 2787 del loaded_tests # Need to destroy test cases before the suite | 2813 del loaded_tests # Need to destroy test cases before the suite |
| 2788 del pyauto_suite | 2814 del pyauto_suite |
| 2789 sys.exit(not result.wasSuccessful()) | 2815 sys.exit(not result.wasSuccessful()) |
| 2790 | 2816 |
| 2791 | 2817 |
| 2792 if __name__ == '__main__': | 2818 if __name__ == '__main__': |
| 2793 Main() | 2819 Main() |
| OLD | NEW |