Skip to content

Commit 5790bd3

Browse files
committed
Updated login page function to be generaic user login, using user_tools
Removed dotenv from requirements Updated existing tests to use new login function
1 parent fba58dc commit 5790bd3

16 files changed

+23
-37
lines changed

pages/login_page.py

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,18 @@ def __init__(self, page: Page):
1313
self.username = page.get_by_role("textbox", name="Username")
1414
self.password = page.get_by_role("textbox", name="Password")
1515
self.submit_button = page.get_by_role("button", name="submit")
16+
load_dotenv() # Take environment variables from .env
1617

17-
def login_as_user_bcss401(self):
18-
"""Logs in to bcss as the test user 'BCSS401'"""
19-
# Take environment variables from .env
20-
load_dotenv()
18+
def login_as_user(self, username: str) -> None:
19+
"""Logs in to bcss with specified user credentials
20+
Args:
21+
username (str) enter a username that exists in users.json
22+
"""
2123
# Retrieve and enter username from users.json
22-
user_details = UserTools.retrieve_user("BCSS401")
24+
user_details = UserTools.retrieve_user(username)
2325
self.username.fill(user_details["username"])
2426
# Retrieve and enter password from .env file
2527
password = os.getenv("BCSS_PASS")
2628
self.password.fill(password)
27-
# Click submit button
28-
self.submit_button.click()
29-
30-
def login_as_user_bcss118(self):
31-
"""Logs in to bcss as the test user 'BCSS118'"""
32-
# Take environment variables from .env
33-
load_dotenv()
34-
# Retrieve and enter username from users.json
35-
user_details = UserTools.retrieve_user("BCSS118")
36-
self.username.fill(user_details["username"])
37-
# Retrieve and enter password from .env file
38-
password = os.getenv("BCSS_PASS")
39-
self.password.fill(password)
40-
# Click submit button
29+
# Click Submit
4130
self.submit_button.click()

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ pytest-html>=4.1.1
33
pytest-json-report>=1.5.0
44

55
playwright~=1.47.0
6-
dotenv~=0.9.9
76
python-dotenv~=1.0.1
87
pytest~=8.3.3
98
Flask~=3.0.3

tests/test_bowel_scope_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def before_each(page: Page):
1111
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the bowel scope page
1212
"""
1313
# Log in to BCSS
14-
BcssLoginPage(page).login_as_user_bcss401()
14+
BcssLoginPage(page).login_as_user("BCSS401")
1515

1616
# Go to bowel scope page
1717
MainMenu(page).go_to_bowel_scope_page()

tests/test_call_and_recall_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def before_each(page: Page):
1111
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the call and recall page
1212
"""
1313
# Log in to BCSS
14-
BcssLoginPage(page).login_as_user_bcss401()
14+
BcssLoginPage(page).login_as_user("BCSS401")
1515

1616
# Go to call and recall page
1717
MainMenu(page).go_to_call_and_recall_page()

tests/test_communications_production_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def before_each(page: Page):
1111
production page
1212
"""
1313
# Log in to BCSS
14-
BcssLoginPage(page).login_as_user_bcss401()
14+
BcssLoginPage(page).login_as_user("BCSS401")
1515

1616
# Go to communications production page
1717
MainMenu(page).go_to_communications_production_page()

tests/test_contacts_list_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def before_each(page: Page):
1111
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the contacts list page
1212
"""
1313
# Log in to BCSS
14-
BcssLoginPage(page).login_as_user_bcss401()
14+
BcssLoginPage(page).login_as_user("BCSS401")
1515

1616
# Go to contacts list page
1717
MainMenu(page).go_to_contacts_list_page()

tests/test_download_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def before_each(page: Page):
1111
Before every test is executed, this fixture logs in to BCSS as a test user and navigates to the download page
1212
"""
1313
# Log in to BCSS
14-
BcssLoginPage(page).login_as_user_bcss401()
14+
BcssLoginPage(page).login_as_user("BCSS401")
1515

1616
# Go to download page
1717
MainMenu(page).go_to_download_page()

tests/test_fit_test_kits_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def before_each(page: Page):
1212
fit test kits page
1313
"""
1414
# Log in to BCSS
15-
BcssLoginPage(page).login_as_user_bcss401()
15+
BcssLoginPage(page).login_as_user("BCSS401")
1616

1717
# Go to fit test kits page
1818
MainMenu(page).go_to_fit_test_kits_page()

tests/test_gfobt_test_kits_page.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def before_each(page: Page):
1212
gfob test kits page
1313
"""
1414
# Log in to BCSS
15-
BcssLoginPage(page).login_as_user_bcss401()
15+
BcssLoginPage(page).login_as_user("BCSS401")
1616

1717
# Go to gFOBT test kits page
1818
MainMenu(page).go_to_gfob_test_kits_page()

tests/test_home_page_links.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def before_each(page: Page):
1212
being displayed
1313
"""
1414
# Log in to BCSS
15-
BcssLoginPage(page).login_as_user_bcss401()
15+
BcssLoginPage(page).login_as_user("BCSS401")
1616

1717

1818
@pytest.mark.smoke

0 commit comments

Comments
 (0)