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 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 u'y': 44}]} | 721 u'y': 44}]} |
722 | 722 |
723 Raises: | 723 Raises: |
724 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 724 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
725 """ | 725 """ |
726 cmd_dict = { # Prepare command for the json interface | 726 cmd_dict = { # Prepare command for the json interface |
727 'command': 'GetBrowserInfo', | 727 'command': 'GetBrowserInfo', |
728 } | 728 } |
729 return self._GetResultFromJSONRequest(cmd_dict) | 729 return self._GetResultFromJSONRequest(cmd_dict) |
730 | 730 |
| 731 def GetNavigationInfo(self, tab_index=0, windex=0): |
| 732 """Get info about the navigation state of a given tab. |
| 733 |
| 734 Args: |
| 735 tab_index: The tab index, default is 0. |
| 736 window_index: The window index, default is 0. |
| 737 |
| 738 Returns: |
| 739 a dictionary. |
| 740 Sample: |
| 741 |
| 742 { u'favicon_url': u'https://www.google.com/favicon.ico', |
| 743 u'page_type': u'NORMAL_PAGE', |
| 744 u'ssl': { u'displayed_insecure_content': False, |
| 745 u'ran_insecure_content': False, |
| 746 u'security_style': u'SECURITY_STYLE_AUTHENTICATED'}} |
| 747 |
| 748 Values for security_style can be: |
| 749 SECURITY_STYLE_UNKNOWN |
| 750 SECURITY_STYLE_UNAUTHENTICATED |
| 751 SECURITY_STYLE_AUTHENTICATION_BROKEN |
| 752 SECURITY_STYLE_AUTHENTICATED |
| 753 |
| 754 Values for page_type can be: |
| 755 NORMAL_PAGE |
| 756 ERROR_PAGE |
| 757 INTERSTITIAL_PAGE |
| 758 """ |
| 759 cmd_dict = { # Prepare command for the json interface |
| 760 'command': 'GetNavigationInfo', |
| 761 'tab_index': tab_index, |
| 762 } |
| 763 return self._GetResultFromJSONRequest(cmd_dict, windex=windex) |
| 764 |
731 def GetHistoryInfo(self, search_text=''): | 765 def GetHistoryInfo(self, search_text=''): |
732 """Return info about browsing history. | 766 """Return info about browsing history. |
733 | 767 |
734 Args: | 768 Args: |
735 search_text: the string to search in history. Defaults to empty string | 769 search_text: the string to search in history. Defaults to empty string |
736 which means that all history would be returned. This is | 770 which means that all history would be returned. This is |
737 functionally equivalent to searching for a text in the | 771 functionally equivalent to searching for a text in the |
738 chrome://history UI. So partial matches work too. | 772 chrome://history UI. So partial matches work too. |
739 When non-empty, the history items returned will contain a | 773 When non-empty, the history items returned will contain a |
740 "snippet" field corresponding to the snippet visible in | 774 "snippet" field corresponding to the snippet visible in |
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1640 if self._options.verbose: | 1674 if self._options.verbose: |
1641 verbosity = 2 | 1675 verbosity = 2 |
1642 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 1676 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
1643 del loaded_tests # Need to destroy test cases before the suite | 1677 del loaded_tests # Need to destroy test cases before the suite |
1644 del pyauto_suite | 1678 del pyauto_suite |
1645 sys.exit(not result.wasSuccessful()) | 1679 sys.exit(not result.wasSuccessful()) |
1646 | 1680 |
1647 | 1681 |
1648 if __name__ == '__main__': | 1682 if __name__ == '__main__': |
1649 Main() | 1683 Main() |
OLD | NEW |