Chromium Code Reviews| Index: chrome/test/functional/passwords.py |
| =================================================================== |
| --- chrome/test/functional/passwords.py (revision 137688) |
| +++ chrome/test/functional/passwords.py (working copy) |
| @@ -4,6 +4,7 @@ |
| # found in the LICENSE file. |
| import os |
| +from urlparse import urlparse |
| import pyauto_functional # Must be imported before pyauto |
| import pyauto |
| @@ -18,6 +19,11 @@ |
| URL = 'https://accounts.google.com/ServiceLogin' |
| URL_HTTPS = 'https://accounts.google.com/Login' |
| URL_LOGOUT = 'https://accounts.google.com/Logout' |
| + HOSTNAME = 'https://'+urlparse(URL)[1] |
|
Ilya Sherman
2012/05/19 07:47:34
nit: HOSTNAME = 'https://' + urlparse(URL).netloc
dyu1
2012/05/22 17:31:38
Done.
|
| + USERNAME_ELEM = 'Email' |
| + PASSWORD_ELEM = 'Passwd' |
| + USERNAME = 'test@google.com' |
| + PASSWORD = 'test.password' |
| def Debug(self): |
| """Test method for experimentation. |
| @@ -80,9 +86,9 @@ |
| window.domAutomationController.send(value); |
| """ |
| self.assertTrue(self.WaitUntil( |
| - lambda: self.ExecuteJavascript(js_template % 'Email', |
| + lambda: self.ExecuteJavascript(js_template % self.USERNAME_ELEM, |
| tab_index, window_index) != '' and |
| - self.ExecuteJavascript(js_template % 'Passwd', |
| + self.ExecuteJavascript(js_template % self.PASSWORD_ELEM, |
| tab_index, window_index) != '')) |
| def testSavePassword(self): |
| @@ -216,23 +222,23 @@ |
| Saved passwords should be autofilled once the username is entered in |
| incognito mode. |
| """ |
| + action_target = self.HOSTNAME |
| + |
| driver = self.NewWebDriver() |
| - username = 'test@google.com' |
| - password = 'test.password' |
| password_dict = self._ConstructPasswordDictionary( |
| - username, password, |
| - 'https://www.google.com/', 'https://www.google.com/accounts', |
| - 'Email', 'Passwd', 'https://www.google.com/accounts') |
| + self.USERNAME, self.PASSWORD, self.HOSTNAME, self.URL, |
| + self.USERNAME_ELEM, self.PASSWORD_ELEM, action_target) |
| self.AddSavedPassword(password_dict) |
| self.RunCommand(pyauto.IDC_NEW_INCOGNITO_WINDOW) |
| self.NavigateToURL(self.URL, 1, 0) |
| # Switch to window 1. |
| driver.switch_to_window(driver.window_handles[1]) |
| - driver.find_element_by_id('Email').send_keys(username + '\t') |
| + driver.find_element_by_id( |
| + self.USERNAME_ELEM).send_keys(self.USERNAME + '\t') |
| incognito_passwd = self.GetDOMValue( |
| 'document.getElementById("Passwd").value', tab_index=0, windex=1) |
| - self.assertEqual(incognito_passwd, password, |
| - msg='Password creds did not autofill in incognito mode.') |
| + self.assertEqual(incognito_passwd, self.PASSWORD, |
| + msg='Password creds did not autofill in incognito mode.') |
| def testInfoBarDisappearByNavigatingPage(self): |
| """Test password infobar is dismissed when navigating to different page.""" |
| @@ -269,8 +275,8 @@ |
| If the password field has autocomplete turned off, then the password infobar |
| should not offer to save the password info. |
| """ |
| - password_info = {'Email': 'test@google.com', |
| - 'Passwd': 'test12345'} |
| + password_info = {'Email': self.USERNAME, |
| + 'Passwd': self.PASSWORD} |
| # Disable one-click login infobar for sync. |
| self.SetPrefs(pyauto.kReverseAutologinEnabled, False) |