diff --git a/__pycache__/set_up.cpython-310.pyc b/__pycache__/set_up.cpython-310.pyc index 992f3ce1735dcce921bd46300d809ed011dc1b9d..0df1c396a1211cfe42ef1bc0804424cb7714b2be 100644 Binary files a/__pycache__/set_up.cpython-310.pyc and b/__pycache__/set_up.cpython-310.pyc differ diff --git a/actions.py b/actions.py index 810cb54b4e60dd25a94eb69ae5afc1ae346f8aac..90169dee641a28826ca2a0be910d226af504c513 100644 --- a/actions.py +++ b/actions.py @@ -52,12 +52,15 @@ def click_prototype_library(driver, logger): def click_create_prototype(driver, logger): driver.find_element(By.XPATH, "//button[text()='Create New Prototype']").click() logger.debug("Clicked the Create New Prototype button") - + def error_handler(logger, configInfo, error_message, exception, email_content, place_occur): logger.error(f"{error_message}: {exception}") - email_subject = f"An error occured in the {place_occur} page" + instance = "local machine" + if ("autowrx-etas.digital.auto" in configInfo["web_url"]): + instance = "autowrx-etas.digital.auto" + email_subject = f"Error occured in the {place_occur} page of {instance}" send_email(configInfo, email_content, email_subject) - + # Postman helper functions def send_email(config, email_content, email_subject): url = config["email_url"] diff --git a/info.json b/info.json index e24bbf0a6e0ecfaa6f89530d9afa6337336dbf2b..b693896ae21311f089f2fa198a18bf5fcf5f2f40 100644 --- a/info.json +++ b/info.json @@ -2,7 +2,7 @@ "web_url": "https://autowrx-etas.digital.auto/", "email_url": "https://backend-core-dev.digital.auto/v2/emails", "test_file": "test_no_data.py", - "developer_email": "my.giangvu@gmail.com", + "developer_email": "vuy4hc@bosch.com", "signIn_email": "vuy4hc@bosch.com", "wrong_password": "31280129850", "correct_password": "blablabla", @@ -11,7 +11,7 @@ "admin_email": "dev@gmail.com", "admin_password": "abcd1234", "Bosch_link": "https://www.bosch.com/", - "Covesa_link": "https://www.covesa.global", + "Covesa_link": "https://covesa.global", "Eclipse_link": "https://www.eclipse.org", "Ferdinand_Steinbeis_Institut_link": "https://ferdinand-steinbeis-institut.de" } diff --git a/main.py b/main.py index c2b8b7435f355acb32ae3517d45aee7b20d0587f..05dbac275a3b0ac3a357b4382b5a36f60db8ad0a 100644 --- a/main.py +++ b/main.py @@ -1,7 +1,6 @@ import os import argparse - def main(): parser = argparse.ArgumentParser( description="Run tests with optional headless mode." @@ -16,9 +15,12 @@ def main(): else: os.environ["HEADLESS"] = "false" - os.system("pytest -v -s test_signInOut.py") - os.system("pytest -v -s test_signUp.py") - + os.system("pytest -v -s --disable-warnings test_model.py") + os.system("pytest -v -s --disable-warnings test_no_data.py") + os.system("pytest -v -s --disable-warnings test_page_traversal.py") + # fixing the test_prototype, will include later + os.system("pytest -v -s --disable-warnings test_signInOut.py") + os.system("pytest -v -s --disable-warnings test_signUp.py") if __name__ == "__main__": main() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 20ce0db18b65502cf07489b4ff82b8648decfcef..718bbfdb22c0522dc0f2514b31de55a0299071e4 100644 Binary files a/requirements.txt and b/requirements.txt differ diff --git a/set_up.py b/set_up.py index 7a085619624970cfcd99c8e878aea45c2caeb8b2..1dde4a3a676258f76a22a85796f3211c36686f63 100644 --- a/set_up.py +++ b/set_up.py @@ -30,7 +30,7 @@ class Base(): def setup_logger(self): # Setting up Logger - timestamp = time.strftime("%H-%M-%S %d-%m-%Y") + timestamp = time.strftime("%H.%M.%S %d-%m-%Y") log_dir = configInfo.get("log_dir", "logs") # Default to "logs" if not specified os.makedirs(log_dir, exist_ok=True) # Ensure the log directory exists self.log_file_name = os.path.join(log_dir, f"logfile {timestamp}.log") diff --git a/test_model.py b/test_model.py index ba784351afb5ba08c2ba9c9d552eb69c38153336..e5ff1caae4400293ca57df44f914151fc259e918 100644 --- a/test_model.py +++ b/test_model.py @@ -24,7 +24,7 @@ class Test_Model(BaseTest, unittest.TestCase): try: createModel_button = self.driver.find_element(By.XPATH, "//button[contains(text(),'Create New Model')]") if (createModel_button.is_displayed()): - error_handler(self.logger, self.congigInfo, "Failure. User did not sign in but can still see the 'Create New Model' button", + error_handler(self.logger, self.configInfo, "Failure. User did not sign in but can still see the 'Create New Model' button", "", self.configError["not_signIn_see_CreateModel"], "Model") except: self.logger.info("Success. Tested the case of not seeing the 'Create New Model' button when not signing in") @@ -71,7 +71,7 @@ class Test_Model(BaseTest, unittest.TestCase): wait.until(expected_conditions.visibility_of_element_located((By.XPATH, f"//label[text()='{expected_name}']"))) self.logger.debug("Created a new model") model_name = self.driver.find_element(By.XPATH, f"//label[text()='{expected_name}']").text - assert (model_name == expected_name) + assert (model_name == 'Model "Automation Test Model" created successfully') self.logger.info("Success. Verified the name of the new model") except Exception as e: error_handler(self.logger, self.configInfo, "Failure. Entered new model name is different from resulting new model name", e, diff --git a/test_page_traversal.py b/test_page_traversal.py index e5fcd089e773597077d0166e6133a08c6a1b6ebf..b01563dd8e15f03a2cd2ea125d5df692bbcd8bfc 100644 --- a/test_page_traversal.py +++ b/test_page_traversal.py @@ -1,7 +1,6 @@ from util import * class Test_PageTraversal(BaseTest, unittest.TestCase): - # NOT DONE, WAIT FOR CONSISTENCY IN THE HREF LINK AND ACTUAL LINK def test_open_links(self): if (self.next is True): self.verify_link("Bosch") @@ -16,7 +15,7 @@ class Test_PageTraversal(BaseTest, unittest.TestCase): self.driver.find_element(By.XPATH, f"//a[@href='{page_url}']").click() windows_opened = self.driver.window_handles self.driver.switch_to.window(windows_opened[1]) - assert (self.driver.current_url == page_url) + assert (page_url in self.driver.current_url) self.logger.info(f"Success. Opened and verified {name} Link") self.driver.close() self.driver.switch_to.window(windows_opened[0]) diff --git a/test_prototype.py b/test_prototype.py index ac6c54cbf58ea796451c74ca59b60481643abc91..406682ac34c247f7f46207e0b981abb272152d5f 100644 --- a/test_prototype.py +++ b/test_prototype.py @@ -11,11 +11,12 @@ class Test_Prototype(BaseTest, unittest.TestCase): self.create_and_verify_prototypeName() self.driver.find_element(By.XPATH, "//button[text()='Open']").click() # Open the prototype detail page - self.use_Dashboard_Config() + self.use_Code_dashboardConfig() self.check_widgetList_content() self.add_widget() + self.use_Dashboard() self.edit_widget() - self.delete_widget() + # self.delete_widget() # Delete the testing prototype token = get_user_info(self.configInfo, "token", "signIn") @@ -40,7 +41,7 @@ class Test_Prototype(BaseTest, unittest.TestCase): wait = WebDriverWait(self.driver, 5) wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[@class='da-label-small mt-4 text-da-accent-500']"))) message = self.driver.find_element(By.XPATH, "//label[@class='da-label-small mt-4 text-da-accent-500']").text - assert (message == "Something went wrong") + assert (message == '"name" is not allowed to be empty') self.logger.info("Success. Tested the case of empty input field when creating new prototype.") except Exception as e: error_handler(self.logger, self.configInfo, "Failure. Empty name field passed", e, @@ -74,8 +75,8 @@ class Test_Prototype(BaseTest, unittest.TestCase): error_handler(self.logger, self.configInfo, "Failure. Incorrect name of the newly created prototype on the right", e, self.configError["wrong_newPrototype_name"], "Model") - def use_Dashboard_Config(self): - self.base.beginOfTest_logFormat("use_Dashboard_Config") + def use_Code_dashboardConfig(self): + self.base.beginOfTest_logFormat("use_Code_dashboardConfig") self.driver.find_element(By.XPATH, "//div[text()='Code']").click() self.driver.find_element(By.XPATH, "//div[text()='Dashboard Config']").click() @@ -101,6 +102,22 @@ class Test_Prototype(BaseTest, unittest.TestCase): error_handler(self.logger, self.configInfo, "Failure. 'Add widget' button did not appear when valid boxes are selected", e, self.configError["addWidget_validBoxes"], "Prototype") + def use_Dashboard(self): + self.base.beginOfTest_logFormat("use_Dashboard") + try: + self.driver.find_element(By.XPATH, "//div[text()='Dashboard']").click() + wait = WebDriverWait(self.driver, 3) + wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//div[@class='col-span-2 row-span-2']/iframe"))) + widget_preview = self.driver.find_element(By.XPATH, "//div[@class='col-span-2 row-span-2']/iframe") + assert (widget_preview.is_displayed()) + following_boxes = self.driver.find_elements(By.XPATH, "//div[@class='col-span-2 row-span-2']/following-sibling::*") + preceeding_boxes = self.driver.find_elements(By.XPATH, "//div[@class='col-span-2 row-span-2']/preceding-sibling::*") + assert (len(preceeding_boxes) == 2 and len(following_boxes) == 7) + self.logger.info("Success. Tested the Dashboard functionality to preview widget.") + time.sleep(2) + except: + print("Error occured in Dashboard") + def check_widgetList_content(self): self.base.beginOfTest_logFormat("check_widgetList_content") try: @@ -110,10 +127,11 @@ class Test_Prototype(BaseTest, unittest.TestCase): except Exception as e: error_handler(self.logger, self.configInfo, "Failure. List of widgets is empty.", e, self.configError["addWidget_widgetList_empty"], "Prototype") - + def add_widget(self): self.base.beginOfTest_logFormat("add_widget") try: + self.driver.find_element(By.XPATH, "(//div[contains(text(), 'Marketplace')])[2]").click() self.driver.find_element(By.XPATH, "//label[text()='Simple Wiper Widget']").click() self.driver.find_element(By.XPATH, "//button[text()='Add selected widget']").click() widget_text = self.driver.find_element(By.XPATH, "//div[text()='Simple Wiper Widget']").text @@ -128,7 +146,8 @@ class Test_Prototype(BaseTest, unittest.TestCase): try: action = ActionChains(self.driver) action.move_to_element(self.driver.find_element(By.XPATH, "//div[text()='Simple Wiper Widget']")).perform() - self.driver.find_element(By.XPATH, "//button[@class='da-btn da-btn-plain da-btn-md !px-0']//*[name()='svg']").click() + self.driver.find_element(By.XPATH, "//button[@class='da-btn da-btn-destructive da-btn-md !px-0']//*[name()='svg']").click() + # self.driver.find_element(By.XPATH, "//div[text()='Delete widget']").click() alert_popup = self.driver.switch_to.alert alert_popup.accept() self.logger.info("Success. Deleted a widget in the Dashboard Config.") @@ -138,6 +157,8 @@ class Test_Prototype(BaseTest, unittest.TestCase): def edit_widget(self): self.base.beginOfTest_logFormat("edit_widget") + self.driver.find_element(By.XPATH, "//div[text()='Code']").click() + self.driver.find_element(By.XPATH, "//div[text()='Dashboard Config']").click() action = ActionChains(self.driver) action.move_to_element(self.driver.find_element(By.XPATH, "//div[text()='Simple Wiper Widget']")).perform() self.driver.find_element(By.XPATH, "//button[@class='da-btn da-btn-plain da-btn-md !px-0 hover:text-da-primary-500']//*[name()='svg']").click() @@ -149,10 +170,16 @@ class Test_Prototype(BaseTest, unittest.TestCase): line_of_code = code_block.find_element(By.XPATH, ".//div[@class='view-line' and .//span[text()='\"Builtin\"']]") line_of_code.click() - for _ in range(2): - action.send_keys(Keys.ARROW_LEFT).perform() - action.send_keys(" Testing").perform() + action1 = ActionChains(self.driver) + action1.send_keys(Keys.ARROW_LEFT).perform() + action2 = ActionChains(self.driver) + action2.send_keys(Keys.ARROW_LEFT).perform() + time.sleep(1) # Small delay to ensure key press is registered + action3 = ActionChains(self.driver) + action3.send_keys(" Testing").perform() + time.sleep(1) # Small delay to ensure key press is registered + action.move_to_element(self.driver.find_element(By.XPATH, "//button[contains(text(), 'Save')]")).perform() self.driver.find_element(By.XPATH, "//button[contains(text(), 'Save')]").click() time.sleep(2) @@ -171,11 +198,11 @@ class Test_Prototype(BaseTest, unittest.TestCase): self.logger.debug("Found the span with text: %s", span.text) found = True break - if not found: + if (found is False): self.logger.debug("Did not find the span with text 'Builtin Testing'") else: assert (span.text == '"Builtin Testing"') - self.logger.info("Success. Tested the case of editing the widget config text.") + self.logger.info("Success. Tested the case of editing the widget config text.") except Exception as e: error_handler(self.logger, self.configInfo, "Failure. Cannot edit the widget config text.", e, diff --git a/test_signInOut.py b/test_signInOut.py index 770ea771bb9bcee1830d1327d1a393e9300683ca..96e70108b786ccf20500f41809728163276f3432 100644 --- a/test_signInOut.py +++ b/test_signInOut.py @@ -38,6 +38,7 @@ class Test_SignIn_SignOut(BaseTest, unittest.TestCase): error_handler(self.logger, self.configInfo, "Failure. Wrong password passed. Broken implementation", e, self.configError["wrong_password_passed"], "Home") + def signIn_valid_password(self): self.base.beginOfTest_logFormat("signIn_valid_password") try: @@ -50,6 +51,7 @@ class Test_SignIn_SignOut(BaseTest, unittest.TestCase): 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") @@ -67,4 +69,4 @@ class Test_SignIn_SignOut(BaseTest, unittest.TestCase): 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 + self.configError["cannot_logOut"], "Home") diff --git a/test_signUp.py b/test_signUp.py index 6a1a1138d9e80aedf57147fb2f45778a97ed02b2..b56c75033b1322015d95f11308f53ecfbae6495e 100644 --- a/test_signUp.py +++ b/test_signUp.py @@ -1,157 +1,5 @@ from util import * -class Test_SignUp(BaseTest, unittest.TestCase): - - # # Test case 1: Enter all info and sign up successfully - # def test_SignUp_successfully(self): - # if (self.next is True): - # click_sign_in(self.driver, self.logger, self.config) - # self.logger.info("Started Signing Up") - # click_register(self.driver, self.logger) - # execute_next = True - # try: - # enter_name(self.driver, self.logger, self.config) - # enter_email(self.driver, self.logger, self.config, self.config["signUp_email"]) - # enter_password(self.driver, self.logger, self.config, "valid", "first_enter") - # enter_password(self.driver, self.logger, self.config, "valid", "re_enter") - # except Exception as e: - # error_message = "Failed to open the Register pop up" - # self.logger.error(f"{error_message}: {e}") - # #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed to open the Register pop up.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button then the Register button</li><li>Wait to see if the Register pop up can be loaded.</li></ol></p></body></html>" - # email_content = "%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%20then%20the%20Register%20button%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" - # email_subject = "Error occured in the Home page" - # send_email(self.config, email_content, email_subject) - # execute_next = False - - # if (execute_next is True): - # try: - # click_register(self.driver, self.logger) - # user_icon = self.driver.find_element(By.XPATH, "//img[@src='/imgs/profile.png']") - # assert (user_icon.is_displayed()) - # self.logger.info("Successfully signed up an account.") - # except Exception as e: - # error_message = "Failed to register an account" - # self.logger.critical(f"{error_message}: {e}") - # #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed to register an account.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button and click the Register button</li><li>Fill in all required fields</li><li>Click Register button to create an account</li><</ol></p></body></html>" - # email_content = "%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" - # email_subject = "Error occured in the Home page" - # send_email(self.config, email_content, email_subject) - - # Test case 2: Enter all info but using existing email, sign up failed and catch the message -> Email taken - def test_signUp_existingEmail(self): - if (self.next is True): - click_sign_in(self.driver, self.logger, self.config) - self.logger.info("Started Signing Up") - click_register(self.driver, self.logger) - execute_next = True - try: - enter_name(self.driver, self.logger, self.config) - enter_email(self.driver, self.logger, self.config, self.config["signIn_email"]) - enter_password(self.driver, self.logger, self.config, "valid", "first_enter") - enter_password(self.driver, self.logger, self.config, "valid", "re_enter") - except Exception as e: - error_message = "Failed to open the Register pop up" - self.logger.error(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed to open the Register pop up.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button then the Register button</li><li>Wait to see if the Register pop up can be loaded.</li></ol></p></body></html>" - email_content = "%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%20then%20the%20Register%20button%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - execute_next = False - - if (execute_next is True): - try: - click_register(self.driver, self.logger) - wait = WebDriverWait(self.driver, 3) - wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[text()='Email already taken']"))) - message = self.driver.find_element(By.XPATH, "//label[text()='Email already taken']").text - assert (message == "Email already taken") - self.logger.info("Successfully tested the case of using existing email.") - except Exception as e: - error_message = "Failed the test - existing email was used to sign up the account. Broken implementation" - self.logger.critical(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed the test - existing email was used to sign up the account. Broken implementation.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button and click the Register button</li><li>Fill in all required fields but use an existing email</li><li>Click Register button to create an account</li><</ol></p></body></html>" - email_content = "%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - - # Test case 3: Confirm password and password is different, catch the message -> "password" and "confirm password" must be the same - def test_signUp_confirmPassword(self): - if (self.next is True): - click_sign_in(self.driver, self.logger, self.config) - self.logger.info("Started Signing Up") - click_register(self.driver, self.logger) - execute_next = True - try: - enter_name(self.driver, self.logger, self.config) - enter_email(self.driver, self.logger, self.config, self.config["signIn_email"]) - enter_password(self.driver, self.logger, self.config, "valid", "first_enter") - enter_password(self.driver, self.logger, self.config, "invalid", "re_enter") - except Exception as e: - error_message = "Failed to open the Register pop up" - self.logger.error(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed to open the Register pop up.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button then the Register button</li><li>Wait to see if the Register pop up can be loaded.</li></ol></p></body></html>" - email_contentt = "%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%20then%20the%20Register%20button%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - execute_next = False - - if (execute_next is True): - try: - click_register(self.driver, self.logger) - wait = WebDriverWait(self.driver, 3) - wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[@class='da-label-small mt-3 block text-da-accent-500']"))) - message = self.driver.find_element(By.XPATH, "//label[@class='da-label-small mt-3 block text-da-accent-500']").text - assert (message == '"password" and "confirm password" must be the same') - self.logger.info("Successfully tested the case of different entered password and confirmed password.") - except Exception as e: - error_message = "Failed the test - confirm password was different from entered password. Broken implementation" - self.logger.critical(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed the test - confirm password was different from entered password. Broken implementation.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button and click the Register button</li><li>Fill in all required fields but enter a different password in the confirm password field</li><li>Click Register button to create an account</li><</ol></p></body></html>" - email_content = "%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - - # Test case 4: Lack 1 field of input, catch the message -> "email" is required - def test_signUp_lackOneField(self): - if (self.next is True): - click_sign_in(self.driver, self.logger, self.config) - self.logger.info("Started Signing Up") - click_register(self.driver, self.logger) - execute_next = True - try: - enter_name(self.driver, self.logger, self.config) - enter_password(self.driver, self.logger, self.config, "valid", "first_enter") - enter_password(self.driver, self.logger, self.config, "valid", "re_enter") - except Exception as e: - error_message = "Failed to open the Register pop up" - self.logger.error(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed to open the Register pop up.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button then the Register button</li><li>Wait to see if the Register pop up can be loaded.</li></ol></p></body></html>" - email_content = "%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%20then%20the%20Register%20button%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - execute_next = False - - if (execute_next is True): - try: - click_register(self.driver, self.logger) - wait = WebDriverWait(self.driver, 3) - wait.until(expected_conditions.visibility_of_element_located((By.XPATH, "//label[@class='da-label-small mt-3 block text-da-accent-500']"))) - message = self.driver.find_element(By.XPATH, "//label[@class='da-label-small mt-3 block text-da-accent-500']").text - assert (message == '"email" is required') - self.logger.info("Successfully tested the case of not entered the email field.") - except Exception as e: - error_message = "Failed the test - empty email field but can still registered. Broken implementation" - self.logger.critical(f"{error_message}: {e}") - #email_content = "<!DOCTYPE html><html lang='en'><body><p>Failed the test - empty email field but can still registered. Broken implementation.</p><p>Steps to Reproduce:</p><ol><li>Navigate to the home page.</li><li>Click the Sign In button and click the Register button</li><li>Fill in all required fields except the email field</li><li>Click Register button to create an account</li><</ol></p></body></html>" - email_content = "%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" - email_subject = "Error occured in the Home page" - send_email(self.config, email_content, email_subject) - - -# Test case 5: Enter all info but invalid email address, catch the message -> this is failing - -from util import * - class Test_SignUp(BaseTest, unittest.TestCase): def test_SignUp(self):