Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/test/pyautolib/pyauto.py

Issue 6994005: Fix password automation hooks to get pyauto test testSavePassword working. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modified PYAUTO_TESTS. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1789 Raises: 1789 Raises:
1790 pyauto_errors.JSONInterfaceError if the automation call returns an error. 1790 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1791 """ 1791 """
1792 cmd_dict = { # Prepare command for the json interface 1792 cmd_dict = { # Prepare command for the json interface
1793 'command': 'ClearBrowsingData', 1793 'command': 'ClearBrowsingData',
1794 'to_remove': to_remove, 1794 'to_remove': to_remove,
1795 'time_period': time_period 1795 'time_period': time_period
1796 } 1796 }
1797 return self._GetResultFromJSONRequest(cmd_dict) 1797 return self._GetResultFromJSONRequest(cmd_dict)
1798 1798
1799 def AddSavedPassword(self, password_dict, window_index=0): 1799 def AddSavedPassword(self, password_dict, windex=0):
1800 """Adds the given username-password combination to the saved passwords. 1800 """Adds the given username-password combination to the saved passwords.
1801 1801
1802 Args: 1802 Args:
1803 password_dict: a dictionary that represents a password. Example: 1803 password_dict: a dictionary that represents a password. Example:
1804 { 'username_value': 'user@example.com', # Required 1804 { 'username_value': 'user@example.com', # Required
1805 'password_value': 'test.password', # Required 1805 'password_value': 'test.password', # Required
1806 'signon_realm': 'https://www.example.com/', # Required 1806 'signon_realm': 'https://www.example.com/', # Required
1807 'time': 1279317810.0, # Can get from time.time() 1807 'time': 1279317810.0, # Can get from time.time()
1808 'origin_url': 'https://www.example.com/login', 1808 'origin_url': 'https://www.example.com/login',
1809 'username_element': 'username', # The HTML element 1809 'username_element': 'username', # The HTML element
1810 'password_element': 'password', # The HTML element 1810 'password_element': 'password', # The HTML element
1811 'submit_element': 'submit', # The HTML element 1811 'submit_element': 'submit', # The HTML element
1812 'action_target': 'https://www.example.com/login/', 1812 'action_target': 'https://www.example.com/login/',
1813 'blacklist': False } 1813 'blacklist': False }
1814 window_index: window index, defaults to 0 1814 windex: window index; defaults to 0 (first window).
1815 1815
1816 *Blacklist notes* To blacklist a site, add a blacklist password with the 1816 *Blacklist notes* To blacklist a site, add a blacklist password with the
1817 following dictionary items: origin_url, signon_realm, username_element, 1817 following dictionary items: origin_url, signon_realm, username_element,
1818 password_element, action_target, and 'blacklist': True. Then all sites that 1818 password_element, action_target, and 'blacklist': True. Then all sites that
1819 have password forms matching those are blacklisted. 1819 have password forms matching those are blacklisted.
1820 1820
1821 Returns: 1821 Returns:
1822 True if adding the password succeeded, false otherwise. In incognito 1822 True if adding the password succeeded, false otherwise. In incognito
1823 mode, adding the password should fail. 1823 mode, adding the password should fail.
1824 1824
1825 Raises: 1825 Raises:
1826 JSONInterfaceError on error. 1826 pyauto_errors.JSONInterfaceError if the automation call returns an error.
1827 """ 1827 """
1828 cmd_dict = { # Prepare command for the json interface 1828 cmd_dict = { # Prepare command for the json interface
1829 'command': 'AddSavedPassword', 1829 'command': 'AddSavedPassword',
1830 'password': password_dict 1830 'password': password_dict
1831 } 1831 }
1832 return self._GetResultFromJSONRequest( 1832 return self._GetResultFromJSONRequest(
1833 cmd_dict, windex=window_index)['password_added'] 1833 cmd_dict, windex=windex)['password_added']
1834 1834
1835 def RemoveSavedPassword(self, password_dict, window_index=0): 1835 def RemoveSavedPassword(self, password_dict, window_index=0):
1836 """Removes the password matching the provided password dictionary. 1836 """Removes the password matching the provided password dictionary.
1837 1837
1838 Args: 1838 Args:
1839 password_dict: A dictionary that represents a password. 1839 password_dict: A dictionary that represents a password.
1840 For an example, see the dictionary in AddSavedPassword. 1840 For an example, see the dictionary in AddSavedPassword.
1841 window_index: The window index, default is 0. 1841 window_index: The window index, default is 0.
1842 """ 1842 """
1843 cmd_dict = { # Prepare command for the json interface 1843 cmd_dict = { # Prepare command for the json interface
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3540 if self._options.verbose: 3540 if self._options.verbose:
3541 verbosity = 2 3541 verbosity = 2
3542 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite) 3542 result = PyAutoTextTestRuner(verbosity=verbosity).run(pyauto_suite)
3543 del loaded_tests # Need to destroy test cases before the suite 3543 del loaded_tests # Need to destroy test cases before the suite
3544 del pyauto_suite 3544 del pyauto_suite
3545 sys.exit(not result.wasSuccessful()) 3545 sys.exit(not result.wasSuccessful())
3546 3546
3547 3547
3548 if __name__ == '__main__': 3548 if __name__ == '__main__':
3549 Main() 3549 Main()
OLDNEW
« chrome/test/functional/passwords.py ('K') | « chrome/test/functional/passwords.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698