Skip to content
This repository has been archived by the owner on Aug 20, 2018. It is now read-only.

Commit

Permalink
Add a test to log in and out of Socorro using Persona
Browse files Browse the repository at this point in the history
  • Loading branch information
bobsilverberg committed Feb 27, 2014
1 parent d9b458b commit 38763a0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pages/home_page.py
Expand Up @@ -4,6 +4,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait

from pages.base_page import CrashStatsBasePage

Expand All @@ -15,6 +16,8 @@ class CrashStatsHomePage(CrashStatsBasePage):
"""
_release_channels_locator = (By.CSS_SELECTOR, '.release_channel')
_last_release_channel_locator = (By.CSS_SELECTOR, '#release_channels .release_channel:last-child')
_browserid_login_locator = (By.CSS_SELECTOR, 'div.login a.browserid-login')
_browserid_logout_locator = (By.CSS_SELECTOR, 'div.login a.browserid-logout')

def __init__(self, testsetup, product=None):
'''
Expand All @@ -25,6 +28,29 @@ def __init__(self, testsetup, product=None):
if product is None:
self.selenium.get(self.base_url)

@property
def is_logged_out(self):
return self.selenium.find_element(*self._browserid_login_locator).is_displayed()

@property
def is_logged_in(self):
return self.selenium.find_element(*self._browserid_logout_locator).is_displayed()

def login(self, user='default'):
self.selenium.find_element(*self._browserid_login_locator).click()
credentials = self.testsetup.credentials[user]

from browserid import BrowserID
pop_up = BrowserID(self.selenium, self.timeout)
pop_up.sign_in(credentials['email'], credentials['password'])
WebDriverWait(self.selenium, self.timeout).until(
lambda s: self.is_logged_in, message='Could not log in within %s seconds.' % self.timeout)

def logout(self):
self.selenium.find_element(*self._browserid_logout_locator).click()
WebDriverWait(self.selenium, self.timeout).until(
lambda s: self.is_logged_out, message='Could not log out within %s seconds.' % self.timeout)

def click_last_product_top_crashers_link(self):
return self.ReleaseChannels(
self.testsetup, self.selenium.find_element(*self._last_release_channel_locator)
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -12,3 +12,4 @@ pytest-xdist==1.8
pytest-mozwebqa==1.1.1
requests==1.2.0
selenium
-e git+https://github.com/mozilla/bidpom.git@master#egg=browserid
9 changes: 9 additions & 0 deletions tests/test_smoke_tests.py
Expand Up @@ -71,3 +71,12 @@ def test_that_exploitable_crash_report_not_displayed_for_not_logged_in_users(sel
csp = CrashStatsHomePage(mozwebqa)
Assert.true('Exploitable Crashes' not in csp.header.report_list)
Assert.false(csp.header.is_exploitable_crash_report_present)

@pytest.mark.nondestructive
def test_login_logout(self, mozwebqa):
csp = CrashStatsHomePage(mozwebqa)
Assert.true(csp.is_logged_out)
csp.login()
Assert.true(csp.is_logged_in)
csp.logout()
Assert.true(csp.is_logged_out)

0 comments on commit 38763a0

Please sign in to comment.