Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dropped support for Selenium RC

  • Loading branch information...
commit 21ef94dc17a0dc276d4235533c85d87873932a95 1 parent 49b5b82
@davehunt authored
View
2  .travis.yml
@@ -6,7 +6,7 @@ python:
- 2.6
- 2.7
-script: py.test --baseurl=http://dev.123done.org --driver=firefox -m travis tests/webdriver
+script: py.test --baseurl=http://dev.123done.org --driver=firefox -m travis tests
env:
- DISPLAY=':99.0'
View
11 browser_id.py
@@ -14,17 +14,12 @@ class BrowserID(object):
RESET_URL_REGEX = 'https?:\/\/(\S+)\/reset_password\?token=(.{48})'
INCLUDE_URL_REGEX = '(https?:\/\/(\S+))\/include\.js'
- def __init__(self, sel, timeout=60):
- self.selenium = sel
- setattr(self.selenium, 'rc', isinstance(self.selenium,
- selenium.selenium))
+ def __init__(self, selenium, timeout=60):
+ self.selenium = selenium
self.timeout = timeout
def sign_in(self, email, password):
"""Signs in using the specified email address and password."""
- if self.selenium.rc:
- from pages.rc.sign_in import SignIn
- else:
- from pages.webdriver.sign_in import SignIn
+ from pages.sign_in import SignIn
sign_in = SignIn(self.selenium, timeout=self.timeout, expect='new')
sign_in.sign_in(email, password)
View
0  pages/webdriver/account_manager.py → pages/account_manager.py
File renamed without changes
View
0  pages/webdriver/base.py → pages/base.py
File renamed without changes
View
0  pages/webdriver/complete_registration.py → pages/complete_registration.py
File renamed without changes
View
0  pages/rc/__init__.py
No changes.
View
60 pages/rc/account_manager.py
@@ -1,60 +0,0 @@
-#!/usr/bin/env python
-
-# 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 base import Base
-
-
-class AccountManager(Base):
-
- _emails_locator = "id('emailList')/descendant::div[contains(@class, 'email')]"
- _edit_password_button_locator = 'css=#edit_password button.edit'
- _old_password_field_locator = 'id=old_password'
- _new_password_field_locator = 'id=new_password'
- _change_password_done_locator = 'id=changePassword'
- _sign_in_locator = 'css=a.signIn'
- _sign_out_locator = 'css=a.signOut'
-
- def __init__(self, selenium, timeout):
- Base.__init__(self, selenium, timeout)
- self.wait_for_element_visible('xpath=%s' % self._emails_locator)
-
- @property
- def emails(self):
- return [self.selenium.get_text('xpath=%s[%s]' % (self._emails_locator, i)) for i in range(1, self.selenium.get_xpath_count(self._emails_locator) + 1)]
-
- def click_edit_password(self):
- """Click edit password to show the new/old password fields"""
- self.selenium.click(self._edit_password_button_locator)
- self.wait_for_element_visible(self._old_password_field_locator)
-
- @property
- def old_password(self):
- """Get the value of the old password field."""
- return self.selenium.get_text(self._old_password_field_locator)
-
- @old_password.setter
- def old_password(self, value):
- """Set the value of the old password field."""
- self.selenium.type(self._old_password_field_locator, value)
-
- @property
- def new_password(self):
- """Get the value of the new password field."""
- return self.selenium.get_text(self._new_password_field_locator)
-
- @new_password.setter
- def new_password(self, value):
- """Set the value of the new password field."""
- self.selenium.type(self._new_password_field_locator, value)
-
- def click_password_done(self):
- """Click password done to save the new password."""
- self.selenium.click(self._change_password_done_locator)
- self.wait_for_element_visible(self._edit_password_button_locator)
-
- def click_sign_out(self):
- self.selenium.click(self._sign_out_locator)
- self.wait_for_element_visible(self._sign_in_locator)
View
44 pages/rc/base.py
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-
-# 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/.
-
-import time
-
-
-class Base(object):
-
- _page_title = 'Mozilla Persona'
-
- def __init__(self, selenium, timeout=60000):
- self.selenium = selenium
- self.timeout = timeout
-
- def switch_to_main_window(self):
- self.selenium.select_window('null')
-
- def wait_for_popup(self, page_title):
- count = 0
- while not page_title in self.selenium.get_all_window_titles():
- time.sleep(1)
- count += 1
- if count == self.timeout / 1000:
- raise Exception('Popup has not loaded')
-
- def wait_for_element_present(self, element):
- count = 0
- while not self.selenium.is_element_present(element):
- time.sleep(1)
- count += 1
- if count == self.timeout / 1000:
- raise Exception(element + ' has not loaded')
-
- def wait_for_element_visible(self, element):
- self.wait_for_element_present(element)
- count = 0
- while not self.selenium.is_visible(element):
- time.sleep(1)
- count += 1
- if count == self.timeout / 1000:
- raise Exception(element + ' is not visible')
View
50 pages/rc/complete_registration.py
@@ -1,50 +0,0 @@
-#!/usr/bin/env python
-
-# 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 base import Base
-
-
-class CompleteRegistration(Base):
-
- _email_locator = 'id=email'
- _password_locator = 'id=password'
- _finish_locator = 'css=div.submit > button'
- _thank_you_locator = 'id=congrats'
-
- def __init__(self, selenium, timeout, expect='success'):
- Base.__init__(self, selenium, timeout)
-
- if expect == 'success':
- self.wait_for_element_visible(self._thank_you_locator)
- elif expect == 'verify':
- self.wait_for_element_visible(self._password_locator)
- else:
- raise Exception('Unknown expect value: %s' % expect)
-
- @property
- def email(self):
- """Get the value of the email field."""
- return self.selenium.get_text(self._email_locator)
-
- @property
- def password(self):
- """Get the value of the password field."""
- return self.selenium.get_text(self._password_locator)
-
- @password.setter
- def password(self, value):
- """Set the value of the password field."""
- self.selenium.type(self._password_locator, value)
-
- def click_finish(self):
- """Clicks the 'finish' button."""
- self.selenium.click(self._finish_locator)
- self.wait_for_element_visible(self._thank_you_locator)
-
- @property
- def thank_you(self):
- """Returns the 'thank you' message."""
- return self.selenium.get_text(self._thank_you_locator)
View
123 pages/rc/sign_in.py
@@ -1,123 +0,0 @@
-#!/usr/bin/env python
-
-# 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 base import Base
-
-
-class SignIn(Base):
-
- _signed_in_email_locator = 'css=label[for=email_0]'
- _email_locator = 'id=email'
- _password_locator = 'id=password'
- _verify_password_locator = 'id=vpassword'
- _next_locator = 'css=button.start'
- _sign_in_locator = 'css=button.returning'
- _sign_in_returning_user_locator = 'id=signInButton'
- _verify_email_locator = 'id=verify_user'
- _check_email_at_locator = 'css=#wait .contents h2 + p strong'
-
- def __init__(self, selenium, timeout, expect='new'):
- Base.__init__(self, selenium, timeout)
-
- if self.selenium.get_title != self._page_title:
- self.wait_for_popup(self._page_title)
- self.selenium.select_pop_up(self._page_title)
-
- if expect == 'new':
- self.wait_for_element_visible(self._email_locator)
- elif expect == 'returning':
- self.wait_for_element_visible(self._sign_in_returning_user_locator)
- else:
- raise Exception('Unknown expect value: %s' % expect)
-
- def close_window(self):
- self.selenium.close()
-
- @property
- def signed_in_email(self):
- """Get the value of the email that is currently signed in."""
- return self.selenium.get_text(self._signed_in_email_locator)
-
- @property
- def email(self):
- """Get the value of the email field."""
- return self.selenium.get_text(self._email_locator)
-
- @email.setter
- def email(self, value):
- """Set the value of the email field."""
- self.selenium.type(self._email_locator, value)
-
- @property
- def password(self):
- """Get the value of the password field."""
- return self.selenium.get_text(self._password_locator)
-
- @password.setter
- def password(self, value):
- """Set the value of the password field."""
- self.selenium.type(self._password_locator, value)
-
- @property
- def verify_password(self):
- """Get the value of the verify password field."""
- return self.selenium.get_text(self._verify_password_locator)
-
- @password.setter
- def verify_password(self, value):
- """Set the value of the verify password field."""
- self.selenium.type(self._verify_password_locator, value)
-
- @property
- def check_email_at_address(self):
- """Get the value of the email address for confirmation."""
- return self.selenium.get_text(self._check_email_at_locator)
-
- def click_next(self, expect='password'):
- """Clicks the 'next' button."""
- self.selenium.click(self._next_locator)
- if expect == 'password':
- self.wait_for_element_visible(self._password_locator)
- elif expect == 'verify':
- self.wait_for_element_visible(self._verify_email_locator)
- else:
- raise Exception('Unknown expect value: %s' % expect)
-
- def click_sign_in(self):
- """Clicks the 'Sign In' button."""
- self.selenium.click(self._sign_in_locator)
- self.selenium.deselect_pop_up()
-
- def click_sign_in_returning_user(self):
- """Clicks the 'sign in' button."""
- self.selenium.click(self._sign_in_returning_user_locator)
- self.selenium.deselect_pop_up()
-
- def click_verify_email(self):
- """Clicks 'verify email' button."""
- self.selenium.click(self._verify_email_locator)
- self.wait_for_element_visible(self._check_email_at_locator)
-
- def sign_in(self, email, password):
- """Signs in using the specified email address and password."""
- self.email = email
- self.click_next(expect='password')
- self.password = password
- self.click_sign_in()
-
- def sign_in_new_user(self, email, password):
- """Requests verification email using the specified email address."""
- self.email = email
- self.click_next(expect='verify')
- self.password = password
- self.verify_password = password
- self.click_verify_email()
- self.close_window()
- self.switch_to_main_window()
-
- def sign_in_returning_user(self):
- """Signs in with the stored user."""
- self.click_sign_in_returning_user()
View
0  pages/webdriver/sign_in.py → pages/sign_in.py
File renamed without changes
View
0  pages/webdriver/__init__.py
No changes.
View
10 tests/webdriver/base.py → tests/base.py
@@ -9,9 +9,9 @@
import requests
from selenium.webdriver.support.ui import WebDriverWait
-from ... import BrowserID
-from ... mocks.user import MockUser
-from .. import restmail
+from .. import BrowserID
+from .. mocks.user import MockUser
+import restmail
class BaseTest(object):
@@ -33,7 +33,7 @@ def log_out(self, selenium, timeout):
def create_verified_user(self, selenium, timeout):
user = MockUser()
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(selenium, timeout, expect='new')
signin.sign_in_new_user(user.primary_email, user.password)
mail = restmail.get_mail(user.primary_email, timeout=timeout)
@@ -41,7 +41,7 @@ def create_verified_user(self, selenium, timeout):
mail[0]['text']).group(0)
selenium.get(verify_url)
- from ...pages.webdriver.complete_registration import CompleteRegistration
+ from .. pages.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(selenium,
timeout,
expect='success')
View
8 tests/webdriver/check_add_email.py → tests/check_add_email.py
@@ -8,9 +8,9 @@
import pytest
-from ... import BrowserID
-from .. import restmail
+from .. import BrowserID
from base import BaseTest
+import restmail
@pytest.mark.nondestructive
@@ -25,7 +25,7 @@ def test_add_email(self, mozwebqa):
self.log_out(mozwebqa.selenium, mozwebqa.timeout)
mozwebqa.selenium.find_element_by_css_selector('#loggedout button').click()
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='returning')
signin.click_add_another_email_address()
signin.new_email = user.additional_emails[0]
@@ -40,7 +40,7 @@ def test_add_email(self, mozwebqa):
mail[0]['text']).group(0)
mozwebqa.selenium.get(confirm_url)
- from ...pages.webdriver.complete_registration import CompleteRegistration
+ from .. pages.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(mozwebqa.selenium,
mozwebqa.timeout,
expect='success')
View
4 tests/webdriver/check_change_password.py → tests/check_change_password.py
@@ -7,7 +7,7 @@
import pytest
from selenium.webdriver.support.ui import WebDriverWait
-from ... import BrowserID
+from .. import BrowserID
from base import BaseTest
@@ -19,7 +19,7 @@ def test_change_password(self, mozwebqa):
user = self.create_verified_user(mozwebqa.selenium, mozwebqa.timeout)
mozwebqa.selenium.get(self.browserid_url(mozwebqa.base_url))
- from ...pages.webdriver.account_manager import AccountManager
+ from .. pages.account_manager import AccountManager
account_manager = AccountManager(mozwebqa.selenium, mozwebqa.timeout)
assert user.primary_email in account_manager.emails
View
8 tests/webdriver/check_reset_password.py → tests/check_reset_password.py
@@ -8,9 +8,9 @@
import pytest
-from ... import BrowserID
-from .. import restmail
+from .. import BrowserID
from base import BaseTest
+import restmail
@pytest.mark.nondestructive
@@ -23,7 +23,7 @@ def test_reset_password(self, mozwebqa):
self.log_out(mozwebqa.selenium, mozwebqa.timeout)
mozwebqa.selenium.find_element_by_css_selector('#loggedout button').click()
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='returning')
signin.click_this_is_not_me()
signin.email = user.primary_email
@@ -46,7 +46,7 @@ def test_reset_password(self, mozwebqa):
mail[1]['text']).group(0)
mozwebqa.selenium.get(reset_url)
- from ...pages.webdriver.complete_registration import CompleteRegistration
+ from .. pages.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(mozwebqa.selenium,
mozwebqa.timeout,
expect='success')
View
14 tests/webdriver/check_sign_in.py → tests/check_sign_in.py
@@ -4,15 +4,13 @@
# 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/.
-import uuid
-
import pytest
from selenium.webdriver.support.ui import WebDriverWait
-from ... import BrowserID
-from ... mocks.user import MockUser
-from .. import restmail
+from .. import BrowserID
+from .. mocks.user import MockUser
from base import BaseTest
+import restmail
@pytest.mark.nondestructive
@@ -26,7 +24,7 @@ def test_sign_in_helper(self, mozwebqa):
lambda s: s.find_element_by_id('loggedin').is_displayed())
def test_sign_in(self, mozwebqa):
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
signin.email = mozwebqa.email
signin.click_next(expect='password')
@@ -39,7 +37,7 @@ def test_sign_in(self, mozwebqa):
@pytest.mark.travis
def test_sign_in_new_user_helper(self, mozwebqa):
user = MockUser()
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
print 'signing in as %s' % user.primary_email
signin.sign_in_new_user(user.primary_email, 'password')
@@ -49,7 +47,7 @@ def test_sign_in_new_user_helper(self, mozwebqa):
@pytest.mark.travis
def test_sign_in_new_user(self, mozwebqa):
user = MockUser()
- from ...pages.webdriver.sign_in import SignIn
+ from .. pages.sign_in import SignIn
signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
print 'signing in as %s' % user.primary_email
signin.email = user.primary_email
View
0  tests/webdriver/conftest.py → tests/conftest.py
File renamed without changes
View
0  tests/rc/__init__.py
No changes.
View
44 tests/rc/base.py
@@ -1,44 +0,0 @@
-#!/usr/bin/env python
-
-# 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/.
-
-import re
-import uuid
-
-import requests
-
-from ... import BrowserID
-from .. import restmail
-
-
-class BaseTest(object):
-
- def browserid_url(self, base_url):
- response = requests.get('%s/' % base_url, verify=False)
- match = re.search(BrowserID.INCLUDE_URL_REGEX, response.content)
- if match:
- return match.group(1)
- else:
- raise Exception('Unable to determine BrowserID URL from %s.' % base_url)
-
- def create_verified_user(self, selenium, timeout):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
- email = '%s@restmail.net' % restmail_username
- password = 'password'
-
- from ...pages.rc.sign_in import SignIn
- signin = SignIn(selenium, timeout, expect='new')
- signin.sign_in_new_user(email, password)
- mail = restmail.get_mail(restmail_username)
- verify_url = re.search(BrowserID.VERIFY_URL_REGEX,
- mail[0]['text']).group(0)
-
- selenium.open(verify_url)
- from ...pages.rc.complete_registration import CompleteRegistration
- complete_registration = CompleteRegistration(selenium,
- timeout,
- expect='success')
- assert 'Thank you' in complete_registration.thank_you
- return (email, password)
View
45 tests/rc/check_change_password.py
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-
-# 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/.
-
-import pytest
-
-from ... import BrowserID
-from base import BaseTest
-
-
-@pytest.mark.nondestructive
-class TestSignIn(BaseTest):
-
- @pytest.mark.travis
- def test_change_password(self, mozwebqa):
- (email, password) = self.create_verified_user(mozwebqa.selenium,
- mozwebqa.timeout)
-
- mozwebqa.selenium.open(self.browserid_url(mozwebqa.base_url))
- from ...pages.rc.account_manager import AccountManager
- account_manager = AccountManager(mozwebqa.selenium, mozwebqa.timeout)
-
- assert email in account_manager.emails
-
- account_manager.click_edit_password()
- account_manager.old_password = password
- new_password = password + '_new'
- account_manager.new_password = new_password
- account_manager.click_password_done()
- account_manager.click_sign_out()
-
- mozwebqa.selenium.open('%s/' % mozwebqa.base_url)
-
- login_locator = 'css=#loggedout button'
- mozwebqa.wait_for_element_visible(mozwebqa, login_locator)
- mozwebqa.selenium.click(login_locator)
-
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in(email, new_password)
-
- logout_locator = 'css=#loggedin a'
- mozwebqa.wait_for_element_visible(mozwebqa, logout_locator)
- assert mozwebqa.selenium.is_visible(logout_locator)
View
79 tests/rc/check_sign_in.py
@@ -1,79 +0,0 @@
-#!/usr/bin/env python
-
-# 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/.
-
-import uuid
-
-import pytest
-
-
-from ... import BrowserID
-from .. import restmail
-from base import BaseTest
-
-
-@pytest.mark.nondestructive
-class TestSignIn(BaseTest):
-
- def test_sign_in_helper(self, mozwebqa):
- browser_id = BrowserID(mozwebqa.selenium, mozwebqa.timeout)
- browser_id.sign_in(mozwebqa.email, mozwebqa.password)
-
- logout_locator = 'css=#loggedin a'
- mozwebqa.wait_for_element_visible(mozwebqa, logout_locator)
- assert mozwebqa.selenium.is_visible(logout_locator)
-
- def test_sign_in(self, mozwebqa):
- from ...pages.rc.sign_in import SignIn
- signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
- signin.email = mozwebqa.email
- signin.click_next(expect='password')
- signin.password = mozwebqa.password
- signin.click_sign_in()
-
- logout_locator = 'css=#loggedin a'
- mozwebqa.wait_for_element_visible(mozwebqa, logout_locator)
- assert mozwebqa.selenium.is_visible(logout_locator)
-
- @pytest.mark.travis
- def test_sign_in_new_user_helper(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
- email = '%s@restmail.net' % restmail_username
-
- from ...pages.rc.sign_in import SignIn
- signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
- print 'signing in as %s' % email
- signin.sign_in_new_user(email, 'password')
- mail = restmail.get_mail(restmail_username)
- assert 'Click to confirm this email address' in mail[0]['text']
-
- @pytest.mark.travis
- def test_sign_in_new_user(self, mozwebqa):
- restmail_username = 'bidpom_%s' % uuid.uuid1()
- email = '%s@restmail.net' % restmail_username
- password = 'password'
-
- from ...pages.rc.sign_in import SignIn
- signin = SignIn(mozwebqa.selenium, mozwebqa.timeout, expect='new')
- print 'signing in as %s' % email
- signin.email = email
- signin.click_next(expect='verify')
- signin.password = password
- signin.verify_password = password
- signin.click_verify_email()
- assert signin.check_email_at_address == email
-
- signin.close_window()
- signin.switch_to_main_window()
- mail = restmail.get_mail(restmail_username)
- assert 'Click to confirm this email address' in mail[0]['text']
-
- @pytest.mark.travis
- def test_sign_in_returning_user(self, mozwebqa):
- self.create_verified_user(mozwebqa.selenium, mozwebqa.timeout)
- mozwebqa.selenium.open('%s/' % mozwebqa.base_url)
- logout_locator = 'css=#loggedin a'
- mozwebqa.wait_for_element_visible(mozwebqa, logout_locator)
- assert mozwebqa.selenium.is_visible(logout_locator)
View
32 tests/rc/conftest.py
@@ -1,32 +0,0 @@
-#!/usr/bin/env python
-
-# 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/.
-
-import time
-
-
-def pytest_runtest_setup(item):
- item.config.option.api = 'rc'
-
-
-def pytest_funcarg__mozwebqa(request):
- mozwebqa = request.getfuncargvalue('mozwebqa')
- mozwebqa.wait_for_element_visible = wait_for_element_visible
- mozwebqa.selenium.open('%s/' % mozwebqa.base_url)
- login_locator = 'css=#loggedout button'
- wait_for_element_visible(mozwebqa, login_locator)
- mozwebqa.selenium.click(login_locator)
- return mozwebqa
-
-
-def wait_for_element_visible(mozwebqa, locator):
- end_time = time.time() + mozwebqa.timeout
- while(True):
- if mozwebqa.selenium.is_visible(locator):
- return True
- time.sleep(0.5)
- if(time.time() > end_time):
- break
- raise Exception('Timeout waiting for element to be visible: %s' % locator)
View
0  tests/webdriver/__init__.py
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.