Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit fd7d7312bcba824611b9e61cf8cd10eea110345e Zac committed Dec 8, 2011
Showing with 369 additions and 0 deletions.
  1. +71 −0 credentials.yaml
  2. +3 −0 mozwebqa.cfg
  3. +69 −0 pages/browser_id.py
  4. +89 −0 pages/page.py
  5. +9 −0 requirements.txt
  6. +64 −0 tests/test_amo.py
  7. +64 −0 tests/test_diresworb.py
71 credentials.yaml
@@ -0,0 +1,71 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla WebQA Selenium Tests.
+#
+# The Initial Developer of the Original Code is
+# Mozilla.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Bebe <florin.strugariu@softvision.ro>
+# Alex Rodionov <p0deje@gmail.com>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+#
+#
+# File contains users data.
+#
+# Each user is a section named with its role
+# and any number of values. At least email,
+# password and name should be present.
+#
+# Example:
+# admin:
+# email: email@site.com
+# password: password
+# name: Test User
+#
+# Still, you are free to add any more data you wish. It will be kept
+# in the same dictionary.
+#
+# Example:
+# admin:
+# email: email@site.com
+# password: password
+# name: Test User
+# username: testuser
+# some_user_data: data
+#
+# The contents of this file are accessible via the pytest-mozwebqa plugin:
+#
+# Example:
+# credentials = mozwebqa.credentials['default']
+# credentials['email']
+
+default:
+ email: <value>
+ password: <value>
+ name: <value>
3 mozwebqa.cfg
@@ -0,0 +1,3 @@
+[DEFAULT]
+api = webdriver
+baseurl = https://www.diresworb.org/
69 pages/browser_id.py
@@ -0,0 +1,69 @@
+#!/usr/bin/env python
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla WebQA Selenium Tests.
+#
+# The Initial Developer of the Original Code is
+# Mozilla.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Bebe <florin.strugariu@softvision.ro>
+# Teodosia Pop <teodosia.pop@softvision.ro>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+
+from pages.page import Page
+from selenium.webdriver.common.by import By
+
+class BrowserID(Page):
+
+ _pop_up_id = '_mozid_signin'
+ _email_locator = (By.ID, 'email')
+ _password_locator = (By.ID, 'password')
+
+ _log_in_button_locator = (By.CSS_SELECTOR, 'button.returning')
+ _next_button_locator = (By.CSS_SELECTOR, 'button.start')
+ _sign_in_locator = (By.ID, 'signInButton')
+
+ def __init__(self, testsetup):
+ Page.__init__(self, testsetup)
+ self.selenium.switch_to_window(self._pop_up_id)
+
+ def login(self, user):
+ credentials = self.testsetup.credentials[user]
+
+ self.selenium.find_element(*self._email_locator).send_keys(credentials['email'])
+ self.selenium.find_element(*self._next_button_locator).click()
+
+ self.selenium.find_element(*self._password_locator).send_keys(credentials['password'])
+ self.selenium.find_element(*self._log_in_button_locator).click()
+
+ def sign_in(self):
+ self.selenium.find_element(*self._sign_in_locator).click()
+ self.selenium.switch_to_window('')
89 pages/page.py
@@ -0,0 +1,89 @@
+#!/usr/bin/env python
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla WebQA Selenium Tests.
+#
+# The Initial Developer of the Original Code is
+# Mozilla.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Zac Campbell
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+'''
+Created on Jun 21, 2010
+
+'''
+from unittestzero import Assert
+from selenium.webdriver.support.ui import WebDriverWait
+from selenium.common.exceptions import NoSuchElementException
+from selenium.common.exceptions import ElementNotVisibleException
+
+
+class Page(object):
+ '''
+ Base class for all Pages
+ '''
+
+ def __init__(self, testsetup):
+ '''
+ Constructor
+ '''
+ self.testsetup = testsetup
+ self.base_url = testsetup.base_url
+ self.selenium = testsetup.selenium
+ self.timeout = testsetup.timeout
+
+ @property
+ def is_the_current_page(self):
+ if self._page_title:
+ WebDriverWait(self.selenium, 10).until(lambda s: self.selenium.title)
+
+ Assert.equal(self.selenium.title, self._page_title,
+ "Expected page title: %s. Actual page title: %s" % (self._page_title, self.selenium.title))
+ return True
+
+ def get_url_current_page(self):
+ return(self.selenium.current_url)
+
+ def is_element_present(self, *locator):
+ self.selenium.implicitly_wait(0)
+ try:
+ self.selenium.find_element(*locator)
+ return True
+ except NoSuchElementException:
+ return False
+ finally:
+ # set back to where you once belonged
+ self.selenium.implicitly_wait(self.testsetup.default_implicit_wait)
+
+ def is_element_visible(self, *locator):
+ try:
+ return self.selenium.find_element(*locator).is_displayed()
+ except NoSuchElementException, ElementNotVisibleException:
+ return False
9 requirements.txt
@@ -0,0 +1,9 @@
+# This pulls in all the libraries needed to run Selenium tests
+# on Mozilla WebQA projects
+
+selenium
+pytest==2.1.3
+pytest-xdist==1.6
+BeautifulSoup==3.2.0
+pytest-mozwebqa
+unittestzero
64 tests/test_amo.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla WebQA Selenium Tests.
+#
+# The Initial Developer of the Original Code is
+# Mozilla.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Bebe <florin.strugariu@softvision.ro>
+# Zac Campbell
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+import pytest
+from unittestzero import Assert
+from pages.home import Home
+
+nondestructive = pytest.mark.nondestructive
+destructive = pytest.mark.destructive
+
+
+class TestAMO:
+
+ @nondestructive
+ def test_user_can_login_and_logout_using_browser_id(self, mozwebqa):
+ """ Test for litmus 7857
+ https://litmus.mozilla.org/show_test.cgi?id=7857
+ Test for litmus 4859
+ https://litmus.mozilla.org/show_test.cgi?id=4859
+ """
+
+ home_page = Home(mozwebqa)
+ home_page.login("browserID")
+ Assert.true(home_page.is_the_current_page)
+ Assert.true(home_page.header.is_user_logged_in)
+
+ home_page.header.click_logout()
+ Assert.false(home_page.header.is_user_logged_in)
64 tests/test_diresworb.py
@@ -0,0 +1,64 @@
+#!/usr/bin/env python
+
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla WebQA Selenium Tests.
+#
+# The Initial Developer of the Original Code is
+# Mozilla.
+# Portions created by the Initial Developer are Copyright (C) 2011
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s): Bebe <florin.strugariu@softvision.ro>
+# Zac Campbell
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+import pytest
+from unittestzero import Assert
+from pages.home import Home
+
+nondestructive = pytest.mark.nondestructive
+destructive = pytest.mark.destructive
+
+
+class TestAMO:
+
+ @nondestructive
+ def test_user_can_login_and_logout_using_browser_id(self, mozwebqa):
+ """ Test for litmus 7857
+ https://litmus.mozilla.org/show_test.cgi?id=7857
+ Test for litmus 4859
+ https://litmus.mozilla.org/show_test.cgi?id=4859
+ """
+
+ home_page = Home(mozwebqa)
+ home_page.login("browserID")
+ Assert.true(home_page.is_the_current_page)
+ Assert.true(home_page.header.is_user_logged_in)
+
+ home_page.header.click_logout()
+ Assert.false(home_page.header.is_user_logged_in)

0 comments on commit fd7d731

Please sign in to comment.