diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/persona/app.py b/tests/python/gaia-ui-tests/gaiatest/apps/persona/app.py index 1627d02d9ff0..cd6a2d465526 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/persona/app.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/persona/app.py @@ -17,102 +17,42 @@ class Persona(Base): _password_input_locator = (By.ID, 'authentication_password') _continue_button_locator = (By.CSS_SELECTOR, '.continue.right') _returning_button_locator = (By.CSS_SELECTOR, 'button.isReturning') - _sign_in_button_locator = (By.ID, 'signInButton') - _this_session_only_button_locator = (By.ID, 'this_is_not_my_computer') - _this_is_not_me_locator = (By.CSS_SELECTOR, 'p.isMobile a.thisIsNotMe') - - _create_password_locator = (By.ID, 'password') - _confirm_password_locator = (By.ID, 'vpassword') - _verify_user_locator = (By.ID, 'verify_user') - - _form_section_locator = (By.CSS_SELECTOR, 'div.vertical div.form_section') def __init__(self, marionette): Base.__init__(self, marionette) - self.marionette.switch_to_frame() - self.wait_for_element_present(*self._persona_frame_locator) def login(self, email, password): - self.switch_to_persona_frame() - # This is a hack until we are able to run test with a clean profile - # if a user was logged in tap this is not me - if self.form_section_id == "selectEmail": - self.wait_for_sign_in_button() - self.tap_this_is_not_me() - - self.wait_for_email_input() + # This only supports logging in with a known user and no existing session self.type_email(email) - self.wait_for_continue_button() self.tap_continue() - # if we login with an unverified user we have to confirm the password - if self.form_section_id == "authentication_form": - self.wait_for_password_input() - self.type_password(password) - self.tap_returning() - elif self.form_section_id == "set_password": - self.type_create_password(password) - self.type_confirm_password(password) - self.tap_verify_user() - else: - raise Exception('Could not log into Persona') + self.type_password(password) + self.tap_returning() + + self.marionette.switch_to_frame() + self.wait_for_element_not_present(*self._persona_frame_locator) + self.apps.switch_to_displayed_app() + + def wait_for_persona_to_load(self): + self.wait_for_element_not_displayed(*self._body_loading_locator) def switch_to_persona_frame(self): - self.wait_for_element_present(*self._persona_frame_locator) - self.frame = self.marionette.find_element(*self._persona_frame_locator) + self.marionette.switch_to_frame() + self.frame = self.wait_for_element_present(*self._persona_frame_locator) self.marionette.switch_to_frame(self.frame) - - self.wait_for_element_not_present(*self._body_loading_locator) + self.wait_for_persona_to_load() def type_email(self, value): - email_field = self.marionette.find_element(*self._email_input_locator) - email_field.send_keys(value) + self.marionette.find_element(*self._email_input_locator).send_keys(value) def type_password(self, value): - password_field = self.marionette.find_element(*self._password_input_locator) - password_field.send_keys(value) - - def type_create_password(self, value): - password_field = self.marionette.find_element(*self._create_password_locator) - password_field.send_keys(value) - - def type_confirm_password(self, value): - password_field = self.marionette.find_element(*self._confirm_password_locator) - password_field.send_keys(value) + self.marionette.find_element(*self._password_input_locator).send_keys(value) def tap_continue(self): self.marionette.find_element(*self._continue_button_locator).tap() self.wait_for_element_not_displayed(*self._continue_button_locator) - - def tap_verify_user(self): - self.marionette.find_element(*self._verify_user_locator).tap() - - def tap_sign_in(self): - self.marionette.find_element(*self._sign_in_button_locator).tap() - - def tap_this_is_not_me(self): - self.marionette.find_element(*self._this_is_not_me_locator).tap() + self.wait_for_element_displayed(*self._password_input_locator) def tap_returning(self): self.marionette.find_element(*self._returning_button_locator).tap() - - def tap_this_session_only(self): - self.marionette.find_element(*self._this_session_only_button_locator).tap() - - @property - def form_section_id(self): - self.wait_for_element_displayed(*self._form_section_locator) - return self.marionette.find_element(*self._form_section_locator).get_attribute('id') - - def wait_for_sign_in_button(self): - self.wait_for_element_displayed(*self._sign_in_button_locator) - - def wait_for_email_input(self): - self.wait_for_element_displayed(*self._email_input_locator) - - def wait_for_password_input(self): - self.wait_for_element_displayed(*self._password_input_locator) - - def wait_for_continue_button(self): - self.wait_for_element_displayed(*self._continue_button_locator) \ No newline at end of file diff --git a/tests/python/gaia-ui-tests/gaiatest/apps/ui_tests/regions/persona.py b/tests/python/gaia-ui-tests/gaiatest/apps/ui_tests/regions/persona.py index 104195ec4bbd..10783fb12359 100644 --- a/tests/python/gaia-ui-tests/gaiatest/apps/ui_tests/regions/persona.py +++ b/tests/python/gaia-ui-tests/gaiatest/apps/ui_tests/regions/persona.py @@ -19,8 +19,9 @@ class Persona(Base): def launch_standard_sign_in(self): self.tap_standard_button() from gaiatest.apps.persona.app import Persona - - return Persona(self.marionette) + persona = Persona(self.marionette) + persona.switch_to_persona_frame() + return persona def switch_to_frame(self): self.wait_for_element_displayed(*self._frame_locator) diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_app.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_app.py index b5c67899f428..810d0f8a9556 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_app.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_app.py @@ -37,9 +37,8 @@ def test_persona_standard_sign_in(self): moz_id.switch_to_frame() persona = moz_id.launch_standard_sign_in() - persona.login(self.user.email, self.user.password) - self.apps.switch_to_displayed_app() + persona.login(self.user.email, self.user.password) moz_id.switch_to_frame() moz_id.wait_for_login_event() diff --git a/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_cookie.py b/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_cookie.py index c1d51f9ab944..425f95c90443 100644 --- a/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_cookie.py +++ b/tests/python/gaia-ui-tests/gaiatest/tests/functional/persona/test_persona_cookie.py @@ -39,15 +39,13 @@ def test_persona_cookie(self): self.wait_for_element_displayed(*self._logged_out_button_locator, timeout=120) login_button = self.marionette.find_element(*self._logged_out_button_locator) - login_button.click() + login_button.tap() persona = Persona(self.marionette) + persona.switch_to_persona_frame() persona.login(self.user.email, self.user.password) - # wait to fall back to browser - self.wait_for_condition(lambda m: self.apps.displayed_app.name == browser.name) - self.apps.switch_to_displayed_app() - + # Back to browser content browser.switch_to_content() self.wait_for_element_displayed(*self._logged_in_button_locator)