This repository has been archived by the owner on Nov 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
/
persona.py
50 lines (38 loc) · 2.01 KB
/
persona.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from marionette.by import By
from gaiatest.apps.base import Base
class Persona(Base):
_app_ready_event = (By.CSS_SELECTOR, 'li.ready')
_app_login_event = (By.CSS_SELECTOR, 'li.login')
_app_logout_event = (By.CSS_SELECTOR, 'li.logout')
_app_login_assertion_text = (By.CSS_SELECTOR, 'li.login div.assertion')
_app_std_request_button_locator = (By.ID, 't-request')
_app_logout_button_locator = (By.ID, 't-logout')
_frame_locator = (By.CSS_SELECTOR, 'iframe[src*="identity"]')
def launch_standard_sign_in(self):
self.tap_standard_button()
from gaiatest.apps.persona.app import Persona
persona = Persona(self.marionette)
persona.switch_to_persona_frame()
return persona
def switch_to_frame(self):
self.wait_for_element_displayed(*self._frame_locator)
self.marionette.switch_to_frame(self.marionette.find_element(*self._frame_locator))
def get_assertion(self):
# Gets the last assertion in the event stream list, use logout event to make sure
# we're done getting assertions
return self.marionette.find_elements(*self._app_login_assertion_text)[-1].text
def tap_standard_button(self):
self.wait_for_element_displayed(*self._app_std_request_button_locator)
self.marionette.find_element(*self._app_std_request_button_locator).tap()
def tap_logout_button(self):
self.wait_for_element_displayed(*self._app_logout_button_locator)
self.marionette.find_element(*self._app_logout_button_locator).tap()
def wait_for_logout_event(self):
self.wait_for_element_displayed(*self._app_logout_event)
def wait_for_ready_event(self):
self.wait_for_element_displayed(*self._app_ready_event)
def wait_for_login_event(self):
self.wait_for_element_displayed(*self._app_login_event)