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 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 Raises: | 1667 Raises: |
1668 pyauto_errors.JSONInterfaceError if the automation call returns an error. | 1668 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
1669 """ | 1669 """ |
1670 cmd_dict = { # Prepare command for the json interface | 1670 cmd_dict = { # Prepare command for the json interface |
1671 'command': 'ClearBrowsingData', | 1671 'command': 'ClearBrowsingData', |
1672 'to_remove': to_remove, | 1672 'to_remove': to_remove, |
1673 'time_period': time_period | 1673 'time_period': time_period |
1674 } | 1674 } |
1675 return self._GetResultFromJSONRequest(cmd_dict) | 1675 return self._GetResultFromJSONRequest(cmd_dict) |
1676 | 1676 |
1677 def AddSavedPassword(self, password_dict, window_index=0): | 1677 def AddSavedPassword(self, password_dict, windex=0): |
1678 """Adds the given username-password combination to the saved passwords. | 1678 """Adds the given username-password combination to the saved passwords. |
1679 | 1679 |
1680 Args: | 1680 Args: |
1681 password_dict: a dictionary that represents a password. Example: | 1681 password_dict: a dictionary that represents a password. Example: |
1682 { 'username_value': 'user@example.com', # Required | 1682 { 'username_value': 'user@example.com', # Required |
1683 'password_value': 'test.password', # Required | 1683 'password_value': 'test.password', # Required |
1684 'signon_realm': 'https://www.example.com/', # Required | 1684 'signon_realm': 'https://www.example.com/', # Required |
1685 'time': 1279317810.0, # Can get from time.time() | 1685 'time': 1279317810.0, # Can get from time.time() |
1686 'origin_url': 'https://www.example.com/login', | 1686 'origin_url': 'https://www.example.com/login', |
1687 'username_element': 'username', # The HTML element | 1687 'username_element': 'username', # The HTML element |
1688 'password_element': 'password', # The HTML element | 1688 'password_element': 'password', # The HTML element |
1689 'submit_element': 'submit', # The HTML element | 1689 'submit_element': 'submit', # The HTML element |
1690 'action_target': 'https://www.example.com/login/', | 1690 'action_target': 'https://www.example.com/login/', |
1691 'blacklist': False } | 1691 'blacklist': False } |
1692 window_index: window index, defaults to 0 | 1692 windex: window index; defaults to 0 (first window). |
1693 | 1693 |
1694 *Blacklist notes* To blacklist a site, add a blacklist password with the | 1694 *Blacklist notes* To blacklist a site, add a blacklist password with the |
1695 following dictionary items: origin_url, signon_realm, username_element, | 1695 following dictionary items: origin_url, signon_realm, username_element, |
1696 password_element, action_target, and 'blacklist': True. Then all sites that | 1696 password_element, action_target, and 'blacklist': True. Then all sites that |
1697 have password forms matching those are blacklisted. | 1697 have password forms matching those are blacklisted. |
1698 | 1698 |
1699 Returns: | 1699 Returns: |
1700 True if adding the password succeeded, false otherwise. In incognito | 1700 True if adding the password succeeded, false otherwise. In incognito |
1701 mode, adding the password should fail. | 1701 mode, adding the password should fail. |
1702 | 1702 |
1703 Raises: | 1703 Raises: |
1704 JSONInterfaceError on error. | 1704 pyauto_errors.JSONInterfaceError if the automation call returns an error. |
1705 """ | 1705 """ |
1706 cmd_dict = { # Prepare command for the json interface | 1706 cmd_dict = { # Prepare command for the json interface |
1707 'command': 'AddSavedPassword', | 1707 'command': 'AddSavedPassword', |
1708 'password': password_dict | 1708 'password': password_dict |
1709 } | 1709 } |
1710 return self._GetResultFromJSONRequest( | 1710 return self._GetResultFromJSONRequest( |
1711 cmd_dict, windex=window_index)['password_added'] | 1711 cmd_dict, windex=windex)['password_added'] |
1712 | 1712 |
1713 def RemoveSavedPassword(self, password_dict, window_index=0): | 1713 def RemoveSavedPassword(self, password_dict, window_index=0): |
1714 """Removes the password matching the provided password dictionary. | 1714 """Removes the password matching the provided password dictionary. |
1715 | 1715 |
1716 Args: | 1716 Args: |
1717 password_dict: A dictionary that represents a password. | 1717 password_dict: A dictionary that represents a password. |
1718 For an example, see the dictionary in AddSavedPassword. | 1718 For an example, see the dictionary in AddSavedPassword. |
1719 window_index: The window index, default is 0. | 1719 window_index: The window index, default is 0. |
1720 """ | 1720 """ |
1721 cmd_dict = { # Prepare command for the json interface | 1721 cmd_dict = { # Prepare command for the json interface |
(...skipping 1675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3397 if self._options.verbose: | 3397 if self._options.verbose: |
3398 verbosity = 2 | 3398 verbosity = 2 |
3399 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) | 3399 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) |
3400 del loaded_tests # Need to destroy test cases before the suite | 3400 del loaded_tests # Need to destroy test cases before the suite |
3401 del pyauto_suite | 3401 del pyauto_suite |
3402 sys.exit(not result.wasSuccessful()) | 3402 sys.exit(not result.wasSuccessful()) |
3403 | 3403 |
3404 | 3404 |
3405 if __name__ == '__main__': | 3405 if __name__ == '__main__': |
3406 Main() | 3406 Main() |
OLD | NEW |