Skip to content
Browse files

Extract the BrowserID URL for accessing the account manager page.

  • Loading branch information...
1 parent edd60af commit 377269d6b045c755150daa8a4b033433dee3e11f @davehunt committed Jun 22, 2012
View
1 browser_id.py
@@ -10,6 +10,7 @@
class BrowserID(object):
VERIFY_URL_REGEX = 'https?:\/\/(\S+)\/verify_email_address\?token=(\S+)'
+ INCLUDE_URL_REGEX = '(https?:\/\/(\S+))\/include\.js'
def __init__(self, sel, timeout=60):
self.selenium = sel
View
2 pages/webdriver/account_manager.py
@@ -62,7 +62,7 @@ def new_password(self, value):
def click_password_done(self):
"""Click password done to save the new password."""
- self.selenium.find_element(*self._change_password_done_locator).click()
+ self.selenium.find_element(*self._change_password_done_locator).click()
WebDriverWait(self.selenium, self.timeout).until(
lambda s: s.find_element(*self._edit_password_button_locator).is_displayed())
View
16 tests/rc/base.py
@@ -7,12 +7,22 @@
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
@@ -23,12 +33,12 @@ def create_verified_user(self, selenium, timeout):
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)
+ mail[0]['text']).group(0)
selenium.open(verify_url)
from ...pages.rc.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(selenium,
- timeout,
- expect='success')
+ timeout,
+ expect='success')
assert 'Thank you' in complete_registration.thank_you
return (email, password)
View
2 tests/rc/check_change_password.py
@@ -18,7 +18,7 @@ def test_change_password(self, mozwebqa):
(email, password) = self.create_verified_user(mozwebqa.selenium,
mozwebqa.timeout)
- mozwebqa.selenium.open('https://login.dev.anosrep.org')
+ mozwebqa.selenium.open(self.browserid_url(mozwebqa.base_url))
from ...pages.rc.account_manager import AccountManager
account_manager = AccountManager(mozwebqa.selenium, mozwebqa.timeout)
View
16 tests/webdriver/base.py
@@ -7,12 +7,22 @@
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
@@ -23,12 +33,12 @@ def create_verified_user(self, selenium, timeout):
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)
+ mail[0]['text']).group(0)
selenium.get(verify_url)
from ...pages.webdriver.complete_registration import CompleteRegistration
complete_registration = CompleteRegistration(selenium,
- timeout,
- expect='success')
+ timeout,
+ expect='success')
assert 'Thank you' in complete_registration.thank_you
return (email, password)
View
2 tests/webdriver/check_change_password.py
@@ -19,7 +19,7 @@ def test_change_password(self, mozwebqa):
(email, password) = self.create_verified_user(mozwebqa.selenium,
mozwebqa.timeout)
- mozwebqa.selenium.get('https://login.dev.anosrep.org')
+ mozwebqa.selenium.get(self.browserid_url(mozwebqa.base_url))
from ...pages.webdriver.account_manager import AccountManager
account_manager = AccountManager(mozwebqa.selenium, mozwebqa.timeout)

0 comments on commit 377269d

Please sign in to comment.
Something went wrong with that request. Please try again.