OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import copy | 5 import copy |
6 import ctypes | 6 import ctypes |
7 import email | 7 import email |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import platform | 10 import platform |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 Arg: | 68 Arg: |
69 test: derived from pyauto.PyUITest - base class for UI test cases | 69 test: derived from pyauto.PyUITest - base class for UI test cases |
70 file_name: name of file to remove | 70 file_name: name of file to remove |
71 """ | 71 """ |
72 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), | 72 downloaded_pkg = os.path.join(test.GetDownloadDirectory().value(), |
73 file_name) | 73 file_name) |
74 pyauto_utils.RemovePath(downloaded_pkg) | 74 pyauto_utils.RemovePath(downloaded_pkg) |
75 pyauto_utils.RemovePath(downloaded_pkg + '.crdownload') | 75 pyauto_utils.RemovePath(downloaded_pkg + '.crdownload') |
76 | 76 |
77 | 77 |
78 def GoogleAccountsLogin(test, username, password, tab_index=0, windex=0): | 78 def GoogleAccountsLogin(test, username, password, |
| 79 tab_index=0, windex=0, url=None): |
79 """Log into Google Accounts. | 80 """Log into Google Accounts. |
80 | 81 |
81 Attempts to login to Google by entering the username/password into the google | 82 Attempts to login to Google by entering the username/password into the google |
82 login page and click submit button. | 83 login page and click submit button. |
83 | 84 |
84 Args: | 85 Args: |
85 test: derived from pyauto.PyUITest - base class for UI test cases. | 86 test: derived from pyauto.PyUITest - base class for UI test cases. |
86 username: users login input. | 87 username: users login input. |
87 password: users login password input. | 88 password: users login password input. |
88 tab_index: The tab index, default is 0. | 89 tab_index: The tab index, default is 0. |
89 windex: The window index, default is 0. | 90 windex: The window index, default is 0. |
| 91 url: an alternative url for login page, if None, original one will be used. |
90 """ | 92 """ |
91 test.NavigateToURL('https://accounts.google.com/', windex, tab_index) | 93 url = url or 'https://accounts.google.com/' |
| 94 test.NavigateToURL(url, windex, tab_index) |
92 email_id = 'document.getElementById("Email").value = "%s"; ' \ | 95 email_id = 'document.getElementById("Email").value = "%s"; ' \ |
93 'window.domAutomationController.send("done")' % username | 96 'window.domAutomationController.send("done")' % username |
94 password = 'document.getElementById("Passwd").value = "%s"; ' \ | 97 password = 'document.getElementById("Passwd").value = "%s"; ' \ |
95 'window.domAutomationController.send("done")' % password | 98 'window.domAutomationController.send("done")' % password |
96 test.ExecuteJavascript(email_id, tab_index, windex) | 99 test.ExecuteJavascript(email_id, tab_index, windex) |
97 test.ExecuteJavascript(password, tab_index, windex) | 100 test.ExecuteJavascript(password, tab_index, windex) |
98 test.assertTrue(test.SubmitForm('gaia_loginform', tab_index, windex)) | 101 test.assertTrue(test.SubmitForm('gaia_loginform', tab_index, windex)) |
99 | 102 |
100 | 103 |
101 def VerifyGoogleAccountCredsFilled(test, username, password, tab_index=0, | 104 def VerifyGoogleAccountCredsFilled(test, username, password, tab_index=0, |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 """This test opens crosh. | 442 """This test opens crosh. |
440 | 443 |
441 This function assumes that no browser windows are open. | 444 This function assumes that no browser windows are open. |
442 """ | 445 """ |
443 self.assertEqual(0, self.GetBrowserWindowCount()) | 446 self.assertEqual(0, self.GetBrowserWindowCount()) |
444 self.OpenCrosh() | 447 self.OpenCrosh() |
445 self.assertEqual(1, self.GetBrowserWindowCount()) | 448 self.assertEqual(1, self.GetBrowserWindowCount()) |
446 self.assertEqual(1, self.GetTabCount(), | 449 self.assertEqual(1, self.GetTabCount(), |
447 msg='Could not open crosh') | 450 msg='Could not open crosh') |
448 self.assertEqual('crosh', self.GetActiveTabTitle()) | 451 self.assertEqual('crosh', self.GetActiveTabTitle()) |
OLD | NEW |