Chromium Code Reviews| Index: functional/passwords.py |
| =================================================================== |
| --- functional/passwords.py (revision 66824) |
| +++ functional/passwords.py (working copy) |
| @@ -3,10 +3,9 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -import pyauto_functional # Must be imported before pyauto |
| +import pyauto_functional |
| import pyauto |
|
Nirnimesh
2010/11/24 10:05:29
leave another blank line
|
| - |
| class PasswordTest(pyauto.PyUITest): |
| """Tests that passwords work correctly""" |
| @@ -42,6 +41,58 @@ |
| self.assertTrue(self.AddSavedPassword(password1)) |
| self.assertEquals(self.GetSavedPasswords(), [password1]) |
| + def _Login(self, url, username, password): |
|
Nirnimesh
2010/11/24 10:05:29
use a similar function from test_utils
|
| + """Method to login into a website. |
| + Takes url, username and password as input. """ |
| + self.NavigateToURL(url) |
| + email_id = 'document.getElementById("Email").value = \"%s\"; ' % username |
| + email_id = email_id + 'window.domAutomationController.send("done")' |
| + password = 'document.getElementById("Passwd").value = \"%s\"; ' % password |
| + password = password + 'window.domAutomationController.send("done")' |
| + self.ExecuteJavascript(email_id); |
| + self.ExecuteJavascript(password); |
| + self.ExecuteJavascript('document.getElementById("gaia_loginform").submit(); ' |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
|
| + 'window.domAutomationController.send("done")') |
| + |
| + def testInfoBarDisappearByNavigatingPage(self): |
| + """Test that Password info is dismissed by navigating to different page.""" |
|
Nirnimesh
2010/11/24 10:05:29
s/info/infobar/
|
| + |
| + url = 'https://www.google.com/accounts/Login?hl=en&continue=https://www.google.com/' |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
|
| + creds = self.GetPrivateInfo()['test_google_account'] |
| + username = creds['username'] |
| + password = creds['password'] |
| + |
| + #Login to Google a/c |
|
Nirnimesh
2010/11/24 10:05:29
leave a space after #
Repeat everywhere
|
| + self._Login(url, username, password) |
| + |
| + #Wait for the info bar to appear |
| + self.WaitForInfobarCount(1) |
|
Nirnimesh
2010/11/24 10:05:29
wrap this inside self.assertTrue()
|
| + self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| + self.NavigateToURL('chrome://history') |
| + self.WaitForInfobarCount(0) |
|
Nirnimesh
2010/11/24 10:05:29
wrap this inside self.assertTrue()
|
| + self.assertEqual('History', self.GetActiveTabTitle()) |
|
Nirnimesh
2010/11/24 10:05:29
why?
|
| + self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| + |
|
Nirnimesh
2010/11/24 10:05:29
remove extra blank line
|
| + |
| + def testInfoBarDisappearByReload(self): |
| + """Test that Password info bar disappears by the page reload.""" |
|
Nirnimesh
2010/11/24 10:05:29
s/info bar/infobar/
|
| + |
| + url = 'https://www.google.com/accounts/Login?hl=en&continue=https://www.google.com/' |
|
Nirnimesh
2010/11/24 10:05:29
80+ chars
|
| + creds = self.GetPrivateInfo()['test_google_account'] |
| + username = creds['username'] |
| + password = creds['password'] |
| + |
| + #Login to Google a/c |
| + self._Login(url, username, password) |
| + |
| + #Wait for the info bar to appear |
| + self.WaitForInfobarCount(1) |
| + self.assertTrue(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| + self.GetBrowserWindow(0).GetTab(0).Reload() |
| + self.WaitForInfobarCount(0) |
| + self.assertFalse(self.GetBrowserInfo()['windows'][0]['tabs'][0]['infobars']) |
| + |
| + |
| if __name__ == '__main__': |
| pyauto_functional.Main() |