class Test_SearchCustomerByEmail_004: baseURL = ReadConfig.get_app_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGen.log_gen() @pytest.mark.regression def test_search_customer_by_email(self, setup): self.logger.info("***** SearchCustomerByEmail_004 *****") self.driver = setup self.driver.get(self.baseURL) self.driver.maximize_window() self.lp = LoginPage(self.driver) self.lp.set_username(self.username) self.lp.set_password(self.password) self.lp.click_login() self.logger.info("***** Login successful *****") self.logger.info("***** Starting Search Customer By Email *****") self.add_cst = AddCustomer(self.driver) self.add_cst.click_on_customers_menu() self.add_cst.click_on_customers_menu_item() self.logger.info("***** Searching customer by emailID *****") search_cst = SearchCustomer(self.driver) search_cst.set_email("*****@*****.**") search_cst.click_search() time.sleep(5) status = search_cst.search_customer_by_email( "*****@*****.**") self.driver.close() self.logger.info("***** TC_SearchCustomerByEmail_004 Finished *****") assert status is True
class Test_003_AddCustomer: base_url = ReadConfig.get_app_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGen.log_gen() @pytest.mark.regression def test_add_customer(self, setup): self.logger.info("***** Test_003_AddCustomer *****") self.driver = setup self.driver.get(self.base_url) self.driver.maximize_window() self.lp = LoginPage(self.driver) self.lp.set_username(self.username) self.lp.set_password(self.password) self.lp.click_login() self.logger.info("***** Login successful *****") self.logger.info("***** Starting Add Customer Test *****") self.add_cust = AddCustomer(self.driver) self.add_cust.click_on_customers_menu() self.add_cust.click_on_customers_menu_item() self.add_cust.click_on_add_new() self.logger.info("***** Providing customer info *****") self.email = random_generator() + "@gmail.com" self.add_cust.set_email(self.email) self.add_cust.set_password("test123") self.add_cust.set_customer_roles("Guests") self.add_cust.set_manager_of_vendor("Vendor 2") self.add_cust.set_gender("Male") self.add_cust.set_first_name("Vlad") self.add_cust.set_last_name("Nire") self.add_cust.set_dob("7/05/1989") # Format: D / MM / YYYY self.add_cust.set_company_name("QA") self.add_cust.set_admin_content("This is for testing.") self.add_cust.click_on_save() self.logger.info("***** Saving customer info *****") self.logger.info("***** Add customer validation started *****") self.msg = self.driver.find_element_by_tag_name("body").text #print(self.msg) if 'customer has been added successfully.' in self.msg: self.logger.info("***** Add customer Test Passed *****") assert True else: self.driver.save_screenshot(".\\Screenshots\\" + "test_add_customer_scr.png") self.logger.error("***** Add customer Test Failed *****") assert False self.driver.close() self.logger.info("***** Ending Add customer test *****")
class Test_002_DTT_Login: base_url = ReadConfig.get_app_url() path = ".\\test_data\\login_data.xlsx" logger = LogGen.log_gen() @pytest.mark.regression def test_login_dtt(self, setup): self.logger.info("***** Test_002_DTT_Login *****") self.logger.info("***** Verifying Login DTT *****") self.driver = setup self.driver.get(self.base_url) self.lp = LoginPage(self.driver) # Get data from excel file self.rows = excel_utils.get_row_count(self.path, 'Sheet1') print(f"Number of rows in Excel: {self.rows}") status_list = [] for r in range(2, self.rows + 1): self.username = excel_utils.read_data(self.path, 'Sheet1', r, 1) self.password = excel_utils.read_data(self.path, 'Sheet1', r, 2) self.expected = excel_utils.read_data(self.path, 'Sheet1', r, 3) self.lp.set_username(self.username) self.lp.set_password(self.password) self.lp.click_login() time.sleep(5) actual_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if actual_title == exp_title: if self.expected == "Passed": self.logger.info("***** Test Passed *****") status_list.append("Passed") elif self.expected == "Failed": self.logger.info("***** Test Failed *****") status_list.append("Failed") self.lp.click_logout() elif actual_title != exp_title: if self.expected == "Passed": self.logger.info("***** Test Failed *****") status_list.append("Failed") elif self.expected == "Failed": self.logger.info("***** Test Passed *****") status_list.append("Passed") if "Failed" in status_list: self.logger.info("***** Login DTT Failed *****") self.driver.close() assert False else: self.logger.info("***** Login DTT Passed *****") self.driver.close() assert True self.logger.info("***** End of Login DTT Test *****")
class Test_001_Login: base_url = ReadConfig.get_app_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGen.log_gen() @pytest.mark.sanity @pytest.mark.regression def test_home_page_title(self, setup): self.logger.info("***** Test_001_Login *****") self.logger.info("***** Verifying Home Page Title *****") self.driver = setup self.driver.get(self.base_url) actual_title = self.driver.title if actual_title == "Your store. Login": self.driver.close() self.logger.info("***** Home Page Title Passed *****") assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_home_page_title.png") self.driver.close() self.logger.error("***** Home Page Title Failed *****") assert False @pytest.mark.sanity @pytest.mark.regression def test_login(self, setup): self.logger.info("***** Test_002_Login *****") self.logger.info("***** Verifying Login *****") self.driver = setup self.driver.get(self.base_url) self.lp = LoginPage(self.driver) self.lp.set_username(self.username) self.lp.set_password(self.password) self.lp.click_login() actual_title = self.driver.title if actual_title == "Dashboard / nopCommerce administration": self.logger.info("***** Login Passed *****") self.driver.close() assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_login.png") self.logger.error("***** Login Failed *****") self.driver.close() assert False