From db54ae09be386b0f5d0b7f9ab5f1b44f0ad21b90 Mon Sep 17 00:00:00 2001 From: Jared Hirsch <ohai@6a68.net> Date: Thu, 16 Aug 2012 13:06:27 -0700 Subject: [PATCH] Squashed 'automation-tests/browserid/' changes from f4063ba..4c10bb2 4c10bb2 Merge pull request #42 from zacc/add_is_this_your_computer a490f28 Add methods and test for 'is this your computer' git-subtree-dir: automation-tests/browserid git-subtree-split: 4c10bb2b2c46b6b56d224f52945b55c4e1c256f1 --- automation-tests/browserid/pages/sign_in.py | 25 +++++++++++++++++-- .../browserid/tests/check_sign_in.py | 25 +++++++++++++++++++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/automation-tests/browserid/pages/sign_in.py b/automation-tests/browserid/pages/sign_in.py index 2a22a4a43..13df85c42 100644 --- a/automation-tests/browserid/pages/sign_in.py +++ b/automation-tests/browserid/pages/sign_in.py @@ -28,6 +28,9 @@ class SignIn(Base): _add_another_email_locator = (By.ID, 'useNewEmail') _new_email_locator = (By.ID, 'newEmail') _add_new_email_locator = (By.ID, 'addNewEmail') + _your_computer_content_locator = (By.ID, 'your_computer_content') + _this_is_my_computer_locator = (By.ID, 'this_is_my_computer') + _this_is_not_my_computer_locator = (By.ID, 'this_is_not_my_computer') def __init__(self, selenium, timeout, expect='new'): Base.__init__(self, selenium, timeout) @@ -161,11 +164,19 @@ class SignIn(Base): self.selenium.find_element(*self._sign_in_locator).click() self.switch_to_main_window() - def click_sign_in_returning_user(self): + def click_sign_in_returning_user(self, expect='login'): """Clicks the 'sign in' button.""" self.selenium.find_element( *self._sign_in_returning_user_locator).click() - self.switch_to_main_window() + + if expect == 'login': + self.switch_to_main_window() + elif expect == 'remember': + WebDriverWait(self.selenium, self.timeout).until( + lambda s: s.find_element( + *self._your_computer_content_locator).is_displayed()) + else: + raise Exception('Unknown expect value: %s' % expect) def click_verify_email(self): """Clicks 'verify email' button.""" @@ -202,6 +213,16 @@ class SignIn(Base): lambda s: s.find_element( *self._check_email_at_locator).is_displayed()) + def click_i_trust_this_computer(self): + """Clicks 'I trust this computer' and signs in """ + self.selenium.find_element(*self._this_is_my_computer_locator).click() + self.switch_to_main_window() + + def click_this_is_not_my_computer(self): + """Clicks 'I trust this computer' and signs in for a public computer""" + self.selenium.find_element(*self._this_is_not_my_computer_locator).click() + self.switch_to_main_window() + def sign_in(self, email, password): """Signs in using the specified email address and password.""" self.email = email diff --git a/automation-tests/browserid/tests/check_sign_in.py b/automation-tests/browserid/tests/check_sign_in.py index a18461685..224d3cc27 100644 --- a/automation-tests/browserid/tests/check_sign_in.py +++ b/automation-tests/browserid/tests/check_sign_in.py @@ -5,6 +5,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import pytest +import time from selenium.webdriver.support.ui import WebDriverWait from .. import BrowserID @@ -72,3 +73,27 @@ class TestSignIn(BaseTest): mozwebqa.selenium.get('%s/' % mozwebqa.base_url) WebDriverWait(mozwebqa.selenium, mozwebqa.timeout).until( lambda s: s.find_element_by_id('loggedin').is_displayed()) + + def test_sign_in_is_this_your_computer(self, mozwebqa): + browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout) + browser_id.sign_in(mozwebqa.email, mozwebqa.password) + + WebDriverWait(mozwebqa.selenium, mozwebqa.timeout).until( + lambda s: s.find_element_by_id('loggedin').is_displayed()) + login_time = time.time() + + self.log_out(mozwebqa.selenium, mozwebqa.timeout) + + while time.time() < (login_time + 60): + time.sleep(15) + mozwebqa.selenium.find_element_by_css_selector('#loggedout button') + + mozwebqa.selenium.find_element_by_css_selector('#loggedout button').click() + + from .. pages.sign_in import SignIn + signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='returning') + signin.click_sign_in_returning_user(expect='remember') + signin.click_i_trust_this_computer() + + WebDriverWait(mozwebqa.selenium, mozwebqa.timeout).until( + lambda s: s.find_element_by_id('loggedin').is_displayed()) -- GitLab