Skip to content
Snippets Groups Projects
Commit ad5caea7 authored by Tam Thai Hoang Minh's avatar Tam Thai Hoang Minh
Browse files

Merge branch 'main' into 'main'

Update test sign in, sign up ang log out

See merge request !7
parents b501261b 472e6d15
No related branches found
No related tags found
1 merge request!7Update test sign in, sign up ang log out
......@@ -2,8 +2,8 @@
logs/
# Ignore Python compiled files
*.pyc
__pycache__/
*.pyc
# Ignore virtual environment directories
venv/
......@@ -13,3 +13,8 @@ env/
*.env
*.tmp
.DS_Store
# Ignore common editor directories and files
.vscode/
.idea/
*.swp
File added
......@@ -2,7 +2,8 @@
"cannot_open_register_popup": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20open%20the%20Register%20pop%20up.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%2C%20then%20click%20Register%3C%2Fli%3E%3Cli%3EWait%20to%20see%20if%20the%20Register%20pop%20up%20can%20be%20loaded.%3C%2Fli%3E%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"cannot_open_signIn_popup": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20open%20the%20Sign%20In%20pop%20up.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%3C%2Fli%3E%3Cli%3EWait%20to%20see%20if%20the%20Sign%20In%20pop%20up%20can%20be%20loaded.%3C%2Fli%3E%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"cannot_register_account": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20register%20an%20account.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%20and%20click%20the%20Register%20button%3C%2Fli%3E%3Cli%3EFill%20in%20all%20required%20fields%3C%2Fli%3E%3Cli%3EClick%20Register%20button%20to%20create%20an%20account%3C%2Fli%3E%3C%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"cannot_signIn_logOut": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20sign%20in%20and%20log%20out%20with%20valid%20password.%20Broken%20implementation.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%3C%2Fli%3E%3Cli%3EClick%20the%20user%20icon%20to%20find%20the%20log%20out%20button.%3C%2Fli%3E%3Cli%3EThen%20click%20log%20out%20button%3C%2Fli%3E%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"cannot_signIn": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20sign%20in%20with%20valid%20password.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%3C%2Fli%3E%3Cli%3EFill%20in%20all%20correct%20information%20to%20sign%20In%20and%20click%20Sign%20In.%3C%2Fli%3E%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"cannot_logOut": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20to%20log%20out%20after%20signing%20in.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3ESign%20In%20with%20your%20account%3C%2Fli%3E%3Cli%3EClick%20the%20user%20icon%20and%20click%20logout.%3C%2Fli%3E%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"existing_email_passed": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20the%20test%20-%20existing%20email%20was%20used%20to%20sign%20up%20the%20account.%20Broken%20implementation.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%20and%20click%20the%20Register%20button%3C%2Fli%3E%3Cli%3EFill%20in%20all%20required%20fields%20but%20use%20an%20existing%20email%3C%2Fli%3E%3Cli%3EClick%20Register%20button%20to%20create%20an%20account%3C%2Fli%3E%3C%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"incorrect_confirm_password": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20the%20test%20-%20confirm%20password%20was%20different%20from%20entered%20password.%20Broken%20implementation.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%20and%20click%20the%20Register%20button%3C%2Fli%3E%3Cli%3EFill%20in%20all%20required%20fields%20but%20enter%20a%20different%20password%20in%20the%20confirm%20password%20field%3C%2Fli%3E%3Cli%3EClick%20Register%20button%20to%20create%20an%20account%3C%2Fli%3E%3C%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
"empty_email_passed": "%3C!DOCTYPE%20html%3E%3Chtml%20lang%3D'en'%3E%3Cbody%3E%3Cp%3EFailed%20the%20test%20-%20empty%20email%20field%20but%20can%20still%20registered.%20Broken%20implementation.%3C%2Fp%3E%3Cp%3ESteps%20to%20Reproduce%3A%3C%2Fp%3E%3Col%3E%3Cli%3ENavigate%20to%20the%20home%20page.%3C%2Fli%3E%3Cli%3EClick%20the%20Sign%20In%20button%20and%20click%20the%20Register%20button%3C%2Fli%3E%3Cli%3EFill%20in%20all%20required%20fields%20except%20the%20email%20field%3C%2Fli%3E%3Cli%3EClick%20Register%20button%20to%20create%20an%20account%3C%2Fli%3E%3C%3C%2Fol%3E%3C%2Fp%3E%3C%2Fbody%3E%3C%2Fhtml%3E",
......
......@@ -55,3 +55,5 @@ class Test_PageTraversal(BaseTest, unittest.TestCase):
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot open Ferdinand Steinbeis Institut Link in the Home Page", e,
self.configError["institut_link_failed"], "Home")
\ No newline at end of file
from util import *
class Test_SignIn(BaseTest, unittest.TestCase):
class Test_SignIn_SignOut(BaseTest, unittest.TestCase):
def test_SignIn_and_SignOut(self):
if ((self.next is True) and (self.open_SignIn_popup() is True)):
self.signIn_invalid_password()
time.sleep(2)
self.signIn_valid_password()
time.sleep(2)
self.logOut()
def open_SignIn_popup(self):
self.base.beginOfTest_logFormat("open_SignIn_popup")
click_sign_in(self.driver, self.logger, self.configInfo)
canOpen_popUp = False
try:
popup = self.driver.find_element(By.TAG_NAME, "form")
assert (popup.is_displayed())
canOpen_popUp = True
self.logger.info("Success. Can open the sign in popup.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot open the Sign In pop up", e,
self.configError["cannot_open_signIn_popup"], "Home")
return canOpen_popUp
# Test case 1: Sign in with invalid password, catch the message -> Invalid username or password
def test_sign_in_invalid_password(self):
if (self.next is True):
self.base.beginOfTest_logFormat("test_sign_in_invalid_password")
self.logger.info("Started Signing In")
click_sign_in(self.driver, self.logger, self.configInfo)
execute_next = True
try:
enter_email(self.driver, self.logger, self.configInfo, self.configInfo["signIn_email"])
enter_password(self.driver, self.logger, self.configInfo, "invalid", "first_enter")
submit_sign_in(self.driver, self.logger)
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot open the Sign In pop up", e,
self.configError["cannot_open_signIn_popup"], "Home")
execute_next = False
if (execute_next is True):
try:
wait = WebDriverWait(self.driver, 2)
wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[text()='Incorrect email or password']")))
login_error = self.driver.find_element(By.XPATH, "//label[text()='Incorrect email or password']").text
assert (login_error == "Incorrect email or password")
self.logger.info("Success. Tested the invalid login attempt.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Wrong password passed. Broken implementation", e,
self.configError["wrong_password_passed"], "Home")
def signIn_invalid_password(self):
self.base.beginOfTest_logFormat("signIn_invalid_password")
try:
enter_email(self.driver, self.logger, self.configInfo, self.configInfo["signIn_email"])
enter_password(self.driver, self.logger, self.configInfo, "invalid", "first_enter")
submit_sign_in(self.driver, self.logger)
wait = WebDriverWait(self.driver, 2)
wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[text()='Incorrect email or password']")))
login_error = self.driver.find_element(By.XPATH, "//label[text()='Incorrect email or password']").text
assert (login_error == "Incorrect email or password")
self.logger.info("Success. Tested the invalid login attempt.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Wrong password passed. Broken implementation", e,
self.configError["wrong_password_passed"], "Home")
# Test case 2: Sign in with valid password, verify the icon on the top right, then sign out
def test_sign_in_valid_password_and_sign_out(self):
if (self.next is True):
self.base.beginOfTest_logFormat("test_sign_in_valid_password_and_sign_out")
self.logger.info("Started Signing In")
click_sign_in(self.driver, self.logger, self.configInfo)
execute_next = True
try:
enter_email(self.driver, self.logger, self.configInfo, self.configInfo["signIn_email"])
enter_password(self.driver, self.logger, self.configInfo, "valid", "first_enter")
submit_sign_in(self.driver, self.logger)
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot open the Sign In pop up", e,
self.configError["cannot_open_signIn_popup"], "Home")
execute_next = False
if (execute_next is True):
try:
wait = WebDriverWait(self.driver, 3)
wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//img[@src='/imgs/profile.png']")))
self.driver.find_element(By.XPATH, "//img[@src='/imgs/profile.png']").click()
self.logger.debug("Clicked the user icon")
wait = WebDriverWait(self.driver, 2)
wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[contains(text(),'Logout')]")))
logout_icon = self.driver.find_element(By.XPATH, "//label[contains(text(),'Logout')]")
assert (logout_icon.text == "Logout")
self.logger.info("Success. Tested signing in with the valid password.")
logout_icon.click()
self.logger.debug("Clicked the logout icon")
signIn_button = self.driver.find_element(By.XPATH, "//button[text()='Sign in']")
assert (signIn_button.is_displayed())
self.logger.info("Success. Tested logging out.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot sign in and log out with valid password. Broken implementation", e,
self.configError["cannot_signIn_logOut"], "Home")
def signIn_valid_password(self):
self.base.beginOfTest_logFormat("signIn_valid_password")
try:
self.driver.find_element(By.XPATH, "//input[@name='password']").clear()
enter_password(self.driver, self.logger, self.configInfo, "valid", "first_enter")
submit_sign_in(self.driver, self.logger)
user_icon = self.driver.find_element(By.TAG_NAME, "picture")
assert (user_icon.is_displayed())
self.logger.info("Success. Tested the valid login attempt.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot sign in with correct password. Broken implementation", e,
self.configError["cannot_signIn"], "Home")
def logOut(self):
self.base.beginOfTest_logFormat("logOut")
try:
self.driver.find_element(By.TAG_NAME, "picture").click()
self.logger.debug("Clicked the user icon")
wait = WebDriverWait(self.driver, 2)
wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[contains(text(),'Logout')]")))
logout_icon = self.driver.find_element(By.XPATH, "//label[contains(text(),'Logout')]")
time.sleep(2)
logout_icon.click()
self.logger.debug("Clicked the logout icon")
signIn_button = self.driver.find_element(By.XPATH, "//button[text()='Sign in']")
assert (signIn_button.is_displayed())
self.logger.info("Success. Tested logging out.")
except Exception as e:
error_handler(self.logger, self.configInfo, "Failure. Cannot log out after signing in.", e,
self.configError["cannot_logOut"], "Home")
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment