Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

All tests use either browserid or username login, depending which is …

…available.
  • Loading branch information...
commit f9bb8d0fa217b138c23f6f3bbd3abdff1115ee23 1 parent f3966f6
@jgerigmeyer jgerigmeyer authored
Showing with 20 additions and 39 deletions.
  1. +2 −2 credentials.yaml
  2. +14 −17 login_page.py
  3. +4 −20 test_homepage.py
View
4 credentials.yaml
@@ -32,7 +32,7 @@
# credentials['username']
default:
- username: <value>
- email: <value>
+ username: <value> # Used if site uses username/password logins instead of BrowserID/Persona.
+ email: <value> # Used if site uses BrowserID/Persona instead of username/password logins.
password: <value>
name: <value>
View
31 login_page.py
@@ -18,32 +18,29 @@ class MozTrapLoginPage(MozTrapBasePage):
_register_locator = 'css=#loginform .form-actions > a'
def login(self, user='default'):
- if type(user) is str:
- user = self.testsetup.credentials[user]
-
- self.type(self._username_locator, user['username'])
- self.type(self._password_locator, user['password'])
- self.click(self._submit_locator, True)
- from home_page import MozTrapHomePage
- return MozTrapHomePage(self.testsetup)
-
- def login_using_browserid(self, user='default'):
- from browserid import BrowserID
from home_page import MozTrapHomePage
if type(user) is str:
user = self.testsetup.credentials[user]
- self.click(self._browserid_locator)
-
- browser_id = BrowserID(self.selenium, timeout=self.timeout)
-
- browser_id.sign_in(user['email'], user['password'])
- self.selenium.wait_for_page_to_load(timeout=self.timeout)
+ if self.is_browserid_visible:
+ from browserid import BrowserID
+ self.click(self._browserid_locator)
+ browser_id = BrowserID(self.selenium, timeout=self.timeout)
+ browser_id.sign_in(user['email'], user['password'])
+ self.selenium.wait_for_page_to_load(timeout=self.timeout)
+ else:
+ self.type(self._username_locator, user['username'])
+ self.type(self._password_locator, user['password'])
+ self.click(self._submit_locator, True)
return MozTrapHomePage(self.testsetup)
@property
+ def is_browserid_visible(self):
+ return self.is_element_visible(self._browserid_locator)
+
+ @property
def is_register_visible(self):
return self.is_element_visible(self._register_locator)
View
24 test_homepage.py
@@ -11,23 +11,7 @@
class TestHomepage(BaseTest):
- def test_that_user_can_login_and_logout(self, mozwebqa_logged_in):
- home_pg = MozTrapHomePage(mozwebqa_logged_in)
-
- user = home_pg.testsetup.credentials['default']
- home_pg.go_to_homepage_page()
-
- Assert.true(home_pg.is_user_logged_in)
- users_name_text = user['name']
- Assert.equal(home_pg.users_name_text, users_name_text)
-
- login_page = home_pg.logout()
-
- Assert.false(home_pg.is_user_logged_in)
- Assert.true(login_page.is_register_visible)
- Assert.true(login_page.is_signin_visible)
-
- def test_that_user_can_login_using_browserid(self, mozwebqa):
+ def test_that_user_can_login_and_logout(self, mozwebqa):
from login_page import MozTrapLoginPage
login_pg = MozTrapLoginPage(mozwebqa)
home_pg = MozTrapHomePage(mozwebqa)
@@ -35,10 +19,8 @@ def test_that_user_can_login_using_browserid(self, mozwebqa):
mozwebqa.selenium.open('/')
Assert.false(home_pg.is_user_logged_in)
- Assert.true(login_pg.is_register_visible)
- Assert.true(login_pg.is_signin_visible)
- login_pg.login_using_browserid()
+ login_pg.login()
user = home_pg.testsetup.credentials['default']
users_name_text = user['name']
@@ -48,6 +30,8 @@ def test_that_user_can_login_using_browserid(self, mozwebqa):
home_pg.logout()
+ Assert.false(home_pg.is_user_logged_in)
+
def test_that_user_can_select_product(self, mozwebqa_logged_in):
home_pg = MozTrapHomePage(mozwebqa_logged_in)
Please sign in to comment.
Something went wrong with that request. Please try again.