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 SendKeyEvent(self, key_code, windex=0, tab_index=0): | |
Nirnimesh
2011/03/18 03:53:29
s/SendKeyEvent/SendWebkitKeyEvent/
to distinguish
Nirnimesh
2011/03/18 03:53:29
Put tab_index arg before windex
dyu1
2011/03/18 20:59:00
Done.
dyu1
2011/03/18 20:59:00
Done.
| |
758 """Send a key event to the browser. | |
Nirnimesh
2011/03/18 03:53:29
Update this description accordingly
dyu1
2011/03/18 20:59:00
Done.
| |
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 | |
Nirnimesh
2011/03/18 03:53:29
need 2 spaces before #
dyu1
2011/03/18 20:59:00
Done.
| |
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 | |
Nirnimesh
2011/03/18 03:53:29
need at least 2 spaces before #
Nirnimesh
2011/03/18 03:53:29
modifying cmd_dict after calling _GetResultFromJSO
dyu1
2011/03/18 20:59:00
Done.
dyu1
2011/03/18 20:59:00
I actually need both since the cmd_dict is two sep
dennis_jeffrey
2011/03/18 21:44:01
Unless I'm mistaken, I think David's actually send
dyu1
2011/03/21 18:42:35
Done.
| |
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 |