Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[behave] | ||
paths=cairis/automatedTest |
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,12 @@ | ||
from selenium import webdriver | ||
from selenium.webdriver.chrome.options import Options | ||
|
||
def before_scenario(context, scenario): | ||
chrome_options = Options() | ||
chrome_options.add_argument("--headless") | ||
chrome_options.add_argument("--window-size=1920x1080") | ||
browser = webdriver.Chrome(chrome_options=chrome_options, executable_path="chromedriver") | ||
context.browser = browser | ||
|
||
def after_scenario(context, scenario): | ||
context.browser.quit() |
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,25 @@ | ||
Feature: Login and Logout | ||
In order to secure CAIRIS | ||
As a Product Owner | ||
I want the application to be secured with a user name and password | ||
|
||
Scenario: Successful Login | ||
Given I have navigated to the CAIRIS web application | ||
When I supply valid credentials | ||
Then I am granted access to the application | ||
|
||
Scenario Outline: Unsuccessful Login | ||
Given I have navigated to the CAIRIS web application | ||
When I supply <username> and <password> | ||
Then I am refused access to the application | ||
|
||
Examples: | ||
| username | password | | ||
| test | incorrect | | ||
| incorrect | test | | ||
| incorrect | incorrect | | ||
|
||
Scenario: Logout | ||
Given I have successfully authenticated with CAIRIS | ||
When I click logout | ||
Then I am returned to the landing page |
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,63 @@ | ||
from selenium.webdriver.support.ui import WebDriverWait | ||
from selenium.common.exceptions import ElementNotVisibleException | ||
|
||
validUsername = 'test' | ||
validPassword = 'test' | ||
|
||
def NavigateToApp(context): | ||
context.browser.get("https://demo.cairis.org") | ||
|
||
def EnterValidCredentials(context): | ||
EnterCredentials(context, validUsername, validPassword) | ||
ClickButtonWithId(context, 'submit') | ||
|
||
def EnterCredentials(context, username, password): | ||
usernameEl = FindElementById(context, 'email') | ||
passwordEl = FindElementById(context, 'password') | ||
|
||
EnterText(usernameEl, username) | ||
EnterText(passwordEl, password) | ||
|
||
def ClickButtonWithId(context, id): | ||
button = FindElementById(context, id) | ||
button.click() | ||
|
||
def FindElementById(context, id): | ||
return context.browser.find_element_by_id(id) | ||
|
||
def EnterText(element, text): | ||
element.send_keys(text) | ||
|
||
def ElementWithIdInvisible(context, id): | ||
elelement = FindElementById(context, id); | ||
assert element.is_displayed is False | ||
|
||
def WaitForSpinningWheelOfDoom(context): | ||
spinningWheelOfDoom = 'displayWrapper' | ||
WaitForInvisibleByClass(context, 'divLoading') | ||
|
||
def WaitForVisibleByClass(context, className): | ||
return WaitForVisibleStateByClass(context, className, True) | ||
|
||
def WaitForInvisibleByClass(context, className): | ||
return WaitForVisibleStateByClass(context, className, False) | ||
|
||
def WaitForVisibleStateByClass(context, className, displayState): | ||
if(displayState == True): | ||
element = WebDriverWait(context.browser, 30, 0.5, (ElementNotVisibleException)).until(lambda x: x.find_element_by_class_name(className).is_displayed()) | ||
else: | ||
element = WebDriverWait(context.browser, 30, 0.5, (ElementNotVisibleException)).until_not(lambda x: x.find_element_by_class_name(className).is_displayed()) | ||
return element | ||
|
||
def WaitForVisibleById(context, id): | ||
return WaitForVisibleStateById(context, id, True) | ||
|
||
def WaitForInvisibleById(context, id): | ||
return WaitForVisibleStateById(context, id, False) | ||
|
||
def WaitForVisibleStateById(context, id, displayState): | ||
if(displayState == True): | ||
element = WebDriverWait(context.browser, 30, 0.5, (ElementNotVisibleException)).until(lambda x: x.find_element_by_id(id).is_displayed()) | ||
else: | ||
element = WebDriverWait(context.browser, 30, 0.5, (ElementNotVisibleException)).until_not(lambda x: x.find_element_by_id(id).is_displayed()) | ||
return element |
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,47 @@ | ||
from behave import * | ||
from GenericSteps import * | ||
|
||
@given('I have navigated to the CAIRIS web application') | ||
def step_impl(context): | ||
NavigateToApp(context) | ||
|
||
@when('I supply valid credentials') | ||
def step_impl(context): | ||
EnterValidCredentials(context) | ||
|
||
@then('I am granted access to the application') | ||
def step_impl(context): | ||
LoggedIn(context) | ||
|
||
@when('I supply {username} and {password}') | ||
def step_impl(context, username, password): | ||
EnterCredentials(context, username, password) | ||
ClickButtonWithId(context, 'submit') | ||
|
||
@then('I am refused access to the application') | ||
def step_impl(context): | ||
assert OnLandingPage(context) is True | ||
|
||
@given('I have successfully authenticated with CAIRIS') | ||
def step_impl(context): | ||
NavigateToApp(context) | ||
EnterValidCredentials(context) | ||
LoggedIn(context) | ||
|
||
@when('I click logout') | ||
def step_impl(context): | ||
logout = context.browser.find_element_by_id('logoutClick') | ||
logout.click() | ||
|
||
@then('I am returned to the landing page') | ||
def step_impl(context): | ||
assert OnLandingPage(context) is True | ||
|
||
def LoggedIn(context): | ||
WaitForSpinningWheelOfDoom(context) | ||
ClickButtonWithId(context, 'homeClick') | ||
|
||
def OnLandingPage(context): | ||
WaitForVisibleById(context, 'email') | ||
WaitForVisibleById(context, 'password') | ||
return True |
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 |
---|---|---|
|
@@ -2,3 +2,5 @@ python-coveralls | |
codecov | ||
#httpretty | ||
git+https://github.com/melor/HTTPretty.git@py33 | ||
selenium | ||
behave |