Skip to content

Commit fba58dc

Browse files
committed
Added .env file to project
Removed negative login tests Removed redundant login method from BcssLoginPage
1 parent 74a11e7 commit fba58dc

File tree

3 files changed

+4
-51
lines changed

3 files changed

+4
-51
lines changed

.env

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# "DO NOT COMMIT THIS FILE"
2+
3+
BCSS_PASS=

pages/login_page.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from utils.user_tools import UserTools
55
from dotenv import load_dotenv
66

7+
78
class BcssLoginPage:
89

910
def __init__(self, page: Page):
@@ -13,17 +14,6 @@ def __init__(self, page: Page):
1314
self.password = page.get_by_role("textbox", name="Password")
1415
self.submit_button = page.get_by_role("button", name="submit")
1516

16-
17-
def login(self, username, password):
18-
"""Logs in to bcss with specified user credentials
19-
Args:
20-
username (str) enter a username
21-
password (str) enter a password
22-
"""
23-
self.username.fill(username)
24-
self.password.fill(password)
25-
self.submit_button.click()
26-
2717
def login_as_user_bcss401(self):
2818
"""Logs in to bcss as the test user 'BCSS401'"""
2919
# Take environment variables from .env

tests/test_login_to_bcss.py

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -13,43 +13,3 @@ def test_successful_login_to_bcss(page: Page) -> None:
1313
BcssLoginPage(page).login_as_user_bcss401()
1414
# Confirm user has successfully signed in and is viewing the bcss homepage
1515
expect(page.locator("#ntshAppTitle")).to_contain_text("Bowel Cancer Screening System")
16-
17-
18-
def test_login_to_bcss_with_invalid_username(page: Page) -> None:
19-
"""
20-
Confirms that a user with a valid password, and invalid username, can NOT log in to bcss
21-
"""
22-
# Take environment variables from .env
23-
load_dotenv()
24-
# Set an invalid username
25-
username = "BCSSZZZ"
26-
# Retrieve valid password from .env file
27-
password = os.getenv("BCSS_PASS")
28-
# Enter valid password with an invalid username and click 'sign in' button
29-
BcssLoginPage(page).login(username, password)
30-
# Confirm error message is displayed
31-
expect(page.locator("body")).to_contain_text("Incorrect username or password.")
32-
33-
34-
def test_login_to_bcss_with_invalid_password(page: Page) -> None:
35-
"""
36-
Confirms that a user with a valid username, and invalid password, can NOT log in to bcss
37-
"""
38-
# Enter a valid username with an invalid password and click 'sign in' button
39-
username = "BCSS401"
40-
password = "zzzzzz"
41-
BcssLoginPage(page).login(username, password)
42-
# Confirm error message is displayed
43-
expect(page.locator("body")).to_contain_text("Incorrect username or password.")
44-
45-
46-
def test_login_to_bcss_with_no_username_or_password(page: Page) -> None:
47-
"""
48-
Confirms that a user can NOT log in to bcss if no credentials are entered in the log in form
49-
"""
50-
# At the login screen, leave the fields empty and click 'sign in' button
51-
username = ""
52-
password = ""
53-
BcssLoginPage(page).login(username, password)
54-
# Login should fail - verify that sign-in button is still visible
55-
expect(page.get_by_role("button", name="submit")).to_be_visible()

0 commit comments

Comments
 (0)