Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 from page_sets.login_helpers import login_utils | 5 from page_sets.login_helpers import login_utils |
| 6 | 6 |
| 7 | 7 |
| 8 def LoginAccount(action_runner, credential, | 8 def LoginDesktopAccount(action_runner, credential, |
| 9 credentials_path=login_utils.DEFAULT_CREDENTIAL_PATH): | 9 credentials_path=login_utils.DEFAULT_CREDENTIAL_PATH): |
| 10 """Logs in into a Dropbox account. | 10 """Logs in into a Dropbox account. |
| 11 | 11 |
| 12 This function navigates the tab into Dropbox's login page and logs in a user | 12 This function navigates the tab into Dropbox's login page and logs in a user |
| 13 using credentials in |credential| part of the |credentials_path| file. | 13 using credentials in |credential| part of the |credentials_path| file. |
| 14 | 14 |
| 15 Args: | 15 Args: |
| 16 action_runner: Action runner responsible for running actions on the page. | 16 action_runner: Action runner responsible for running actions on the page. |
| 17 credential: The credential to retrieve from the credentials file (string). | 17 credential: The credential to retrieve from the credentials file (string). |
| 18 credentials_path: The path to credential file (string). | 18 credentials_path: The path to credential file (string). |
| 19 | 19 |
| 20 Raises: | 20 Raises: |
| 21 exceptions.Error: See ExecuteJavaScript() | 21 exceptions.Error: See ExecuteJavaScript() |
| 22 for a detailed list of possible exceptions. | 22 for a detailed list of possible exceptions. |
| 23 """ | 23 """ |
| 24 account_name, password = login_utils.GetAccountNameAndPassword( | 24 account_name, password = login_utils.GetAccountNameAndPassword( |
| 25 credential, credentials_path=credentials_path) | 25 credential, credentials_path=credentials_path) |
| 26 | 26 |
| 27 action_runner.Navigate('https://www.pandora.com/account/sign-in') | 27 action_runner.Navigate('https://www.pinterest.com/login/') |
| 28 action_runner.Wait(1) # Error page happens if this wait is not here. | |
|
petrcermak
2016/10/03 09:01:23
Any chance this could be replaced with action_runn
rnephew (Reviews Here)
2016/10/03 16:57:12
Nope. Its there, it just goes to an error page if
| |
| 28 login_utils.InputWithSelector( | 29 login_utils.InputWithSelector( |
| 29 action_runner, account_name, 'input[id=login_username]') | 30 action_runner, '%s@gmail.com' % account_name, 'input[type=email]') |
| 30 login_utils.InputWithSelector( | 31 login_utils.InputWithSelector( |
| 31 action_runner, password, 'input[id=login_password]') | 32 action_runner, password, 'input[type=password]') |
| 32 | 33 |
| 33 login_button_function = ('document.getElementsByClassName(' | 34 login_button_function = ( |
| 34 '"onboarding__form__button onboarding__b1 ' | 35 'document.getElementsByClassName("Button Module btn hasText large ' |
| 35 'onboarding__form__button--blue loginButton")[0]') | 36 'primary continueButton rounded")[0]') |
| 37 action_runner.WaitForElement(element_function=login_button_function) | |
| 36 action_runner.ClickElement(element_function=login_button_function) | 38 action_runner.ClickElement(element_function=login_button_function) |
| 39 | |
| 40 search_bar_function = ( | |
| 41 'document.getElementsByClassName("Input Module field")[0]') | |
| 42 action_runner.WaitForElement(element_function=search_bar_function) | |
| OLD | NEW |