-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from alphagov/selenisation-of-tests
Selenisation of tests
- Loading branch information
Showing
19 changed files
with
727 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
Flask>=0.8 | ||
Flask>=0.10.1 | ||
Flask-Cache==0.13.1 | ||
twilio>=3.3.6 | ||
beautifulsoup4>=4.4.0 | ||
pep8==1.5.7 | ||
pytest==2.8.1 | ||
requests==2.9.1 | ||
retry==0.9.1 | ||
selenium==2.53.1 | ||
|
||
git+https://github.com/alphagov/notifications-python-client.git@0.3.1#egg=notifications-python-client==0.4.1 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import uuid | ||
import pytest | ||
|
||
from selenium import webdriver | ||
|
||
from config import Config | ||
|
||
uuid_for_test_run = str(uuid.uuid1()) | ||
|
||
|
||
def _generate_unique_email(email, uuid_): | ||
parts = email.split('@') | ||
return "{}+{}@{}".format(parts[0], uuid_, parts[1]) | ||
|
||
functional_test_name = Config.FUNCTIONAL_TEST_NAME + uuid_for_test_run | ||
functional_test_email = _generate_unique_email(Config.FUNCTIONAL_TEST_EMAIL, uuid_for_test_run) | ||
functional_test_service_name = Config.FUNCTIONAL_TEST_SERVICE_NAME + uuid_for_test_run | ||
functional_test_password = Config.FUNCTIONAL_TEST_PASSWORD | ||
functional_test_mobile = Config.TWILIO_TEST_NUMBER | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def test_profile(): | ||
return {'name': functional_test_name, | ||
'email': functional_test_email, | ||
'service_name': functional_test_service_name, | ||
'password': functional_test_password, | ||
'mobile': functional_test_mobile} | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def driver(request): | ||
driver = webdriver.Firefox() | ||
|
||
def clear_up(): | ||
driver.delete_all_cookies() | ||
driver.close() | ||
|
||
request.addfinalizer(clear_up) | ||
return driver | ||
|
||
|
||
@pytest.fixture(scope="session") | ||
def base_url(): | ||
return Config.NOTIFY_ADMIN_URL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .pages import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
|
||
from tests.pages.locators import ( | ||
CommonPageLocators, | ||
TwoFactorPageLocators, | ||
SignUpPageLocators, | ||
AddServicePageLocators, | ||
EditTemplatePageLocators, | ||
UploadCsvLocators | ||
) | ||
|
||
|
||
class BasePageElement(object): | ||
|
||
def __set__(self, obj, value): | ||
driver = obj.driver | ||
WebDriverWait(driver, 100).until( | ||
lambda driver: driver.find_element_by_name(self.locator)) | ||
driver.find_element_by_name(self.locator).send_keys(value) | ||
|
||
def __get__(self, obj, owner): | ||
driver = obj.driver | ||
WebDriverWait(driver, 100).until( | ||
lambda driver: driver.find_element_by_name(self.locator)) | ||
element = driver.find_element_by_name(self.locator) | ||
return element.get_attribute("value") | ||
|
||
|
||
class ServiceInputElement(BasePageElement): | ||
locator = AddServicePageLocators.SERVICE_INPUT[1] | ||
|
||
|
||
class EmailInputElement(BasePageElement): | ||
locator = CommonPageLocators.EMAIL_INPUT[1] | ||
|
||
|
||
class PasswordInputElement(BasePageElement): | ||
locator = CommonPageLocators.PASSWORD_INPUT[1] | ||
|
||
|
||
class SmsInputElement(BasePageElement): | ||
locator = TwoFactorPageLocators.SMS_INPUT[1] | ||
|
||
|
||
class NameInputElement(BasePageElement): | ||
locator = CommonPageLocators.NAME_INPUT[1] | ||
|
||
|
||
class MobileInputElement(BasePageElement): | ||
locator = SignUpPageLocators.MOBILE_INPUT[1] | ||
|
||
|
||
class TemplateContentElement(BasePageElement): | ||
locator = EditTemplatePageLocators.TEMPLATE_CONTENT_INPUT[1] | ||
|
||
|
||
class FileInputElement(BasePageElement): | ||
locator = UploadCsvLocators.FILE_INPUT[1] | ||
|
||
|
||
class SubjectInputElement(BasePageElement): | ||
locator = EditTemplatePageLocators.TEMPLATE_SUBJECT_INPUT[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from selenium.webdriver.common.by import By | ||
|
||
|
||
class CommonPageLocators(object): | ||
NAME_INPUT = (By.NAME, 'name') | ||
EMAIL_INPUT = (By.NAME, 'email_address') | ||
PASSWORD_INPUT = (By.NAME, 'password') | ||
CONTINUE_BUTTON = (By.CLASS_NAME, 'button') | ||
|
||
|
||
class MainPageLocators(object): | ||
SETUP_ACCOUNT_BUTTON = (By.CLASS_NAME, 'button') | ||
|
||
|
||
class SignUpPageLocators(object): | ||
MOBILE_INPUT = (By.NAME, 'mobile_number') | ||
|
||
|
||
class TwoFactorPageLocators(object): | ||
SMS_INPUT = (By.NAME, 'sms_code') | ||
|
||
|
||
class AddServicePageLocators(object): | ||
SERVICE_INPUT = (By.NAME, 'name') | ||
ADD_SERVICE_BUTTON = (By.CLASS_NAME, 'button') | ||
|
||
|
||
class DashboardPageLocators(object): | ||
H2 = (By.CLASS_NAME, 'navigation-service-name') | ||
SMS_TEMPLATES_LINK = (By.LINK_TEXT, 'Text message templates') | ||
EMAIL_TEMPLATES_LINK = (By.LINK_TEXT, 'Email templates') | ||
|
||
|
||
class NavigationLocators(object): | ||
SIGN_OUT_LINK = (By.LINK_TEXT, 'Sign out') | ||
|
||
|
||
class TemplatePageLocators(object): | ||
SEND_FROM_CSV_LINK = (By.LINK_TEXT, 'Send from a CSV file') | ||
NEW_TEMPLATE_LINK = (By.LINK_TEXT, 'Add a new template') | ||
|
||
|
||
class EditTemplatePageLocators(object): | ||
TEMPLATE_SUBJECT_INPUT = (By.NAME, 'subject') | ||
TEMPLATE_CONTENT_INPUT = (By.NAME, 'template_content') | ||
SAVE_BUTTON = (By.CLASS_NAME, 'button') | ||
|
||
|
||
class UploadCsvLocators(object): | ||
FILE_INPUT = (By.ID, 'file') | ||
SEND_BUTTON = (By.CLASS_NAME, 'button') |
Oops, something went wrong.