Skip to content

Commit 68df1f0

Browse files
stiwarisemanticbitsShivam Tiwari
andauthored
BB2-4174: Fixed selenium tests (#1399)
* BB2-4174: Fixing selenium tests * fixed port * Fixed remote selenium test * Removed p flag * fixed quotes * fixed test * Fixed * Fixed * Fixed --------- Co-authored-by: Shivam Tiwari <[email protected]>
1 parent d162144 commit 68df1f0

File tree

4 files changed

+47
-19
lines changed

4 files changed

+47
-19
lines changed

apps/accounts/fixtures/scopes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@
208208
"group": 5,
209209
"description": "Launch with FHIR Patient context.",
210210
"protected_resources": "[]",
211-
"default": "False"
211+
"default": "True"
212212
}
213213
}
214214
]

apps/integration_tests/selenium_cases.py

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
HOSTNAME_URL = os.environ['HOSTNAME_URL']
66
USE_NEW_PERM_SCREEN = os.environ['USE_NEW_PERM_SCREEN']
7+
USE_LOGIN_WITH_MEDICARE_BUTTON = os.getenv('USE_LOGIN_WITH_MEDICARE_BUTTON', 'false')
78
PROD_URL = 'https://api.bluebutton.cms.gov'
89
USER_ACTIVATION_PATH_FMT = "{}/v1/accounts/activation-verify/{}"
910

@@ -134,11 +135,13 @@ class Action(Enum):
134135
APP_CSS_SELECTOR_DELETE_APP = ".cta-button:nth-child(2)"
135136

136137
# SLSX login form
137-
SLSX_TXT_FLD_USERNAME = "username-textbox"
138-
SLSX_TXT_FLD_PASSWORD = "password-textbox"
138+
SLSX_TXT_FLD_USERNAME = 'username'
139+
SLSX_TXT_FLD_PASSWORD = 'password'
139140
SLSX_TXT_FLD_USERNAME_VAL = "BBUser00001"
140141
SLSX_TXT_FLD_PASSWORD_VAL = "PW00001!"
141142
SLSX_CSS_BUTTON = "login-button"
143+
SLSX_CSS_CONTINUE_BUTTON = "button[type='submit']"
144+
SLSX_CSS_LOGIN_BUTTON = "//button[@type='submit' and (normalize-space(text())='Log in' or normalize-space(text())='Entrar')]"
142145

143146
# Demographic info access grant form
144147
BTN_ID_GRANT_DEMO_ACCESS = "approve"
@@ -266,22 +269,42 @@ class Action(Enum):
266269
},
267270
]
268271

269-
SEQ_LOGIN_SLSX = [
272+
LOGIN_WITH_MEDICARE_BUTTON_SETUP = []
273+
if USE_LOGIN_WITH_MEDICARE_BUTTON == 'true':
274+
LOGIN_WITH_MEDICARE_BUTTON_SETUP = [{
275+
"display": "Click 'Log in with Medicare.gov' button",
276+
"action": Action.FIND_CLICK,
277+
"params": [
278+
20,
279+
By.CSS_SELECTOR,
280+
"button.ds-c-button.ds-c-button--solid.ds-u-margin-top--2"
281+
],
282+
}]
283+
284+
SEQ_LOGIN_SLSX = LOGIN_WITH_MEDICARE_BUTTON_SETUP + [
285+
270286
{
271287
"display": "Medicare.gov login username",
272288
"action": Action.FIND_SEND_KEY,
273-
"params": [20, By.ID, SLSX_TXT_FLD_USERNAME, SLSX_TXT_FLD_USERNAME_VAL]
289+
"params": [20, By.NAME, SLSX_TXT_FLD_USERNAME, SLSX_TXT_FLD_USERNAME_VAL]
274290
},
291+
{
292+
"display": "Click 'Continue' on SLSX login form",
293+
"action": Action.FIND_CLICK,
294+
"params": [20, By.CSS_SELECTOR, SLSX_CSS_CONTINUE_BUTTON]
295+
},
296+
WAIT_SECONDS,
275297
{
276298
"display": "Medicare.gov login password",
277299
"action": Action.FIND_SEND_KEY,
278-
"params": [20, By.ID, SLSX_TXT_FLD_PASSWORD, SLSX_TXT_FLD_PASSWORD_VAL]
300+
"params": [20, By.NAME, SLSX_TXT_FLD_PASSWORD, SLSX_TXT_FLD_PASSWORD_VAL]
279301
},
280302
{
281-
"display": "Click 'submit' on SLSX login form",
303+
"display": "Click 'Log In' on SLSX login form",
282304
"action": Action.FIND_CLICK,
283-
"params": [20, By.ID, SLSX_CSS_BUTTON]
305+
"params": [20, By.XPATH, SLSX_CSS_LOGIN_BUTTON]
284306
},
307+
WAIT_SECONDS
285308
]
286309

287310
SEQ_REACH_AUTHORIZE_BTN = [

docker-compose/run_selenium_tests_local.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ display_usage() {
3939
echo "Options:"
4040
echo
4141
echo "-h Print this Help."
42-
echo "-p Use new permissions screen (defaults to old style screen)."
4342
echo "-g Selenium grid used - hub on port 4444."
4443
echo "-t Show test case actions on std out."
4544
echo
@@ -74,7 +73,7 @@ echo_msg
7473
set -e -u -o pipefail
7574

7675
export USE_MSLSX=true
77-
export USE_NEW_PERM_SCREEN=false
76+
export USE_NEW_PERM_SCREEN=true
7877
export SERVICE_NAME="selenium-tests"
7978
export TESTS_LIST="./apps/integration_tests/selenium_tests.py ./apps/integration_tests/selenium_spanish_tests.py"
8079
export DJANGO_SETTINGS_MODULE="hhs_oauth_server.settings.dev"
@@ -93,8 +92,6 @@ while getopts "hpgt" option; do
9392
h)
9493
display_usage
9594
exit;;
96-
p)
97-
export USE_NEW_PERM_SCREEN=true;;
9895
g)
9996
export SELENIUM_GRID=true;;
10097
t)

docker-compose/run_selenium_tests_remote.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ display_usage() {
2525
echo "Options:"
2626
echo
2727
echo "-h Print this Help."
28-
echo "-p Test for newer permissions screen. Defaults to older screen."
2928
echo "-g Selenium grid used."
3029
echo "-t Show test case actions on std out."
30+
echo '-l Use Login with Medicare.gov button'
3131
echo
3232
echo "Examples:"
3333
echo
34-
echo "run_selenium_tests_remote.sh -p https://sandbox.bluebutton.cms.gov/ (or SBX)"
34+
echo "run_selenium_tests_remote.sh https://sandbox.bluebutton.cms.gov/ (or SBX)"
3535
echo
3636
echo "run_selenium_tests_remote.sh https://api.bluebutton.cms.gov/ (or PROD)"
3737
echo
38-
echo "run_selenium_tests_remote.sh -p https://test.bluebutton.cms.gov/ (or TEST)"
38+
echo "run_selenium_tests_remote.sh https://test.bluebutton.cms.gov/ (or TEST)"
3939
echo
4040
echo "<bb2 server url> default to SBX (https://sandbox.bluebutton.cms.gov/)"
4141
echo
@@ -50,7 +50,8 @@ echo_msg
5050
# Set bash builtins for safety
5151
set -e -u -o pipefail
5252

53-
export USE_NEW_PERM_SCREEN=false
53+
USE_LOGIN_WITH_MEDICARE_BUTTON="${USE_LOGIN_WITH_MEDICARE_BUTTON:-}"
54+
export USE_NEW_PERM_SCREEN=true
5455
export SERVICE_NAME="selenium-tests-remote"
5556
# TODO optionally add the Spanish selenium tests here if desired
5657
export TESTS_LIST="./apps/integration_tests/selenium_tests.py ./apps/integration_tests/selenium_spanish_tests.py"
@@ -66,10 +67,10 @@ while getopts "hpgt" option; do
6667
h)
6768
display_usage;
6869
exit;;
69-
p)
70-
export USE_NEW_PERM_SCREEN=true;;
7170
g)
7271
export SELENIUM_GRID=true;;
72+
l)
73+
export USE_LOGIN_WITH_MEDICARE_BUTTON=true;;
7374
t)
7475
export PYTEST_SHOW_TRACE_OPT='-s';;
7576
\?)
@@ -93,6 +94,9 @@ then
9394
;;
9495
TEST)
9596
export HOSTNAME_URL="https://test.bluebutton.cms.gov/"
97+
if [[ -z "${USE_LOGIN_WITH_MEDICARE_BUTTON}" ]]; then
98+
export USE_LOGIN_WITH_MEDICARE_BUTTON=true
99+
fi
96100
;;
97101
*)
98102
if [[ ${last_arg} == 'http'* ]]
@@ -111,6 +115,7 @@ fi
111115
SYSTEM=$(uname -s)
112116

113117
echo "USE_NEW_PERM_SCREEN=" ${USE_NEW_PERM_SCREEN}
118+
echo "USE_LOGIN_WITH_MEDICARE_BUTTON=" ${USE_LOGIN_WITH_MEDICARE_BUTTON}
114119
echo "BB2 Server URL=" ${HOSTNAME_URL}
115120
echo "Selenium grid=" ${SELENIUM_GRID}
116121

@@ -119,7 +124,10 @@ export USE_MSLSX=false
119124

120125
# stop all before run selenium remote tests
121126
docker compose -f docker-compose.selenium.remote.yml down --remove-orphans
122-
docker compose -f docker-compose.selenium.remote.yml run selenium-remote-tests bash -c "SELENIUM_GRID=${SELENIUM_GRID} pytest ${PYTEST_SHOW_TRACE_OPT} ${TESTS_LIST}"
127+
docker compose -f docker-compose.selenium.remote.yml run selenium-remote-tests bash -c \
128+
"SELENIUM_GRID=${SELENIUM_GRID} \
129+
USE_LOGIN_WITH_MEDICARE_BUTTON=${USE_LOGIN_WITH_MEDICARE_BUTTON} \
130+
pytest ${PYTEST_SHOW_TRACE_OPT} ${TESTS_LIST}"
123131

124132
# Stop containers after use
125133
echo_msg

0 commit comments

Comments
 (0)