class Test_002_NavigateToNationalities: logger = LogGeneration.logGeneration() # Getting logger baseUrl = "https://staging.riseapp.co.za/timesheet/my-list/weekly/" username = ReadConfig.getUsername() password = ReadConfig.getPassword() @pytest.mark.sanity @pytest.mark.regression def test_NavigateToNationalities(self, setup): self.logger.info("******** Test_002_NavigateToNationalities ********") self.driver = setup self.driver.get(self.baseUrl) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() self.navigate = NavigateToNationalities(self.driver) self.navigate.navigate() act_title = self.driver.title expected_title = "Nationalities" if act_title == expected_title: self.driver.save_screenshot(".\\screenshots\\" + "test_NavigateToNationalities.png") self.logger.info("******** NavigateToNationalities Test passed ********") self.driver.close() assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_NavigateToNationalities.png") self.driver.close() self.logger.info("******** NavigateToNationalitiesTest failed ********") assert False
class Test_001_Login: baseUrl = ReadConfig.getApplicationURL() username = ReadConfig.getUsername() password = ReadConfig.getPassword() logger = LogGeneration.logGeneration() # Getting logger @pytest.mark.regression def test_Login(self, setup): self.logger.info("********Test_001_Login********") self.logger.info("********Verifying Login test********") self.driver = setup self.driver.get(self.baseUrl) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() act_title = self.driver.title expected_title = "My timesheet list weekly" if act_title == expected_title: self.driver.save_screenshot(".\\screenshots\\" + "test_Login.png") self.driver.close() self.logger.info("******** Login Test passed ********") assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_Login.png") self.driver.close() self.logger.info("******** Login Test failed ********") assert False
class Test003AddCustomer: baseURL = ReadConfig.get_application_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGeneration.log_generation() @pytest.mark.sanity def test_add_customer(self, setup): self.logger.info("************* Test_003_AddCustomer *************") self.driver = setup self.driver.maximize_window() self.driver.get(self.baseURL) # Creating an object of Login Page class self.login_page = LoginPage(self.driver) self.login_page.set_username(self.username) self.login_page.set_password(self.password) self.login_page.click_login() self.logger.info("Login successful") self.logger.info("Starting add customer test") # Creating an object of Add Customer Page class self.add_customer_page = AddCustomerPage(self.driver) self.add_customer_page.click_customer_menu() time.sleep(2) self.add_customer_page.click_customer() self.add_customer_page.click_add_new() self.logger.info("Entering new customer information") self.email = random_generator() + '@gmail.com' self.add_customer_page.set_email(self.email) self.add_customer_page.set_password('test123') self.add_customer_page.set_first_name('John') self.add_customer_page.set_last_name('Doe') self.add_customer_page.set_gender('Male') self.add_customer_page.set_dob('11/11/1996') self.add_customer_page.set_company('busyQA') self.add_customer_page.set_tax_exempt() self.add_customer_page.set_newsletter('Test store 2') self.add_customer_page.set_customer_roles('Vendors') self.add_customer_page.set_manager_of_vendor('Vendor 1') self.add_customer_page.set_active() self.add_customer_page.set_admin_comment('This is a new customer for testing purpose') self.add_customer_page.click_save() self.logger.info("Saving new customer information") self.logger.info("Add customer validation started") self.success_msg = self.driver.find_element_by_tag_name('body').text if 'customer has been added successfully' in self.success_msg: assert True self.logger.info("Add customer test passed") else: self.driver.save_screenshot("./Screenshots/test_add_customer.png") self.logger.error("Add customer test case failed") assert False
class Test_OO1_Login: baseURL = ReadConfig.readApplicationURL() username = ReadConfig.readUserEmail() password = ReadConfig.readPassword() logger = LogGeneration.loggen() def test_HomePageTitle(self, setup): self.logger.info( "******************** Test_OO1_Login Started ********************") self.logger.info( "******************** Verifying Home Page Title********************" ) self.driver = setup self.driver.get(self.baseURL) actual_title = self.driver.title if actual_title == "Your store. Login": assert True self.driver.close() self.logger.info( "******************** Verifying Home Page Title test passed********************" ) else: self.driver.save_screenshot(Constants.PARENTDIRECTORY + "\\Screenshots\\" + "test_HomePageTitle.png") self.driver.close() self.logger.error( "******************** Home Page Title test failed********************" ) assert False @pytest.mark.sanity @pytest.mark.regression def test_login(self, setup): self.logger.info( "******************** Verifying Login Test ********************") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() actual_title = self.driver.title if actual_title == "Dashboard / nopCommerce administration": assert True self.driver.close() self.logger.info( "******************** Login test Passed********************") else: self.driver.save_screenshot(Constants.PARENTDIRECTORY + "\\Screenshots\\" + "test_login.png") self.driver.close() self.logger.error( "******************** Login test Failed********************") assert False
class Test_005_EditNationality: baseUrl = "https://staging.riseapp.co.za/lookup/nationalities/list/" username = ReadConfig.getUsername() password = ReadConfig.getPassword() oldName = ReadConfig.getName() faker = Faker() name = faker.name() description = faker.text() ReadConfig.setNationality(name) ReadConfig.setDescription(description) logger = LogGeneration.logGeneration() # Getting logger @pytest.mark.sanity @pytest.mark.regression def test_EditNationality(self, setup): self.logger.info("******** Test_005_EditNationality ********") self.logger.info("******** Verifying Edit Nationality********") self.driver = setup self.driver.get(self.baseUrl) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() self.editNationality = EditNationalityPage(self.driver) self.editNationality.clickAddedName(self.oldName) time.sleep(3) self.editNationality.clickEdit() self.editNationality.setName(self.name) self.editNationality.setDescription(self.description) self.editNationality.clickSave() act_title = self.driver.title expected_title = "Nationalities" if act_title == expected_title: self.driver.save_screenshot(".\\screenshots\\" + "test_EditNationality.png") self.driver.close() self.logger.info("******** Edit Nationality Test passed ********") assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_EditNationality.png") self.driver.close() self.logger.info("******** Edit Nationality Test failed ********") assert False
class Test_OO2_DDT_Login: baseURL = ReadConfig.readApplicationURL() message_error = ReadConfig.readErrorMessage() xml_path = "C:\\Users\\okeyb\\Documents\\Pycharm\\SeleniumFramework\\TestData\\TestData.xml" logger = LogGeneration.loggen() def test_login(self, setup): self.logger.info( "******************** Test_OO2_DDT_Login ********************") self.logger.info( "******************** Verifying Login DDT Test ********************" ) self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) list_status = [] expected_output = [] login_data_values = ReadXML.readXMLFile(self.xml_path) for credentials in login_data_values: self.username = credentials.get("username") self.password = credentials.get("password") self.output = credentials.get("output") expected_output.append(self.output) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: self.logger.info( "******************** Login test Passed ********************" ) self.lp.clickLogout() list_status.append("Pass") elif self.lp.getErrorMessage() == self.message_error: self.logger.info( "******************** Invalid Login test Passed ********************" ) list_status.append("Fail") # if "Fail" not in list_status: # self.logger.info("********** Data Driven Test Passed **********") # self.driver.close() # assert True # else: # self.logger.info("********** Data Driven Test Failed **********") # self.driver.close() # assert False self.logger.info("********** End of Data Driven Test **********")
class Test001Login: baseURL = ReadConfig.get_application_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGeneration.log_generation() @pytest.mark.regression def test_homepage_title(self, setup): self.logger.info("************* Test_001_Login *************") self.logger.info("*** Started home page title test ***") self.driver = setup self.driver.maximize_window() self.logger.info("Opening application URL") self.driver.get(self.baseURL) actual_title = self.driver.title if actual_title == "Your store. Login": self.logger.info("Home page title test is passed") assert True else: self.logger.error("Home page title test is failed") self.driver.save_screenshot( "./Screenshots/test_homepage_title.png") assert False @pytest.mark.sanity @pytest.mark.regression def test_login(self, setup): self.logger.info("*** Started login test ***") self.driver = setup self.driver.maximize_window() self.driver.get(self.baseURL) # Creating an object of LoginPage class self.login_page = LoginPage(self.driver) self.login_page.set_username(self.username) self.login_page.set_password(self.password) self.login_page.click_login() actual_title = self.driver.title if actual_title == "Dashboard / nopCommerce administration": self.logger.info("Login test is passed") assert True else: self.logger.error("Login test is failed") self.driver.save_screenshot("./Screenshots/test_login.png") assert False
class Test_006_DeleteNationality: baseUrl = "https://staging.riseapp.co.za/lookup/nationalities/list/" username = ReadConfig.getUsername() password = ReadConfig.getPassword() name = ReadConfig.getName() logger = LogGeneration.logGeneration() # Getting logger @pytest.mark.regression def test_DeleteNationality(self, setup): self.logger.info("******** Test_006_DeleteNationality ********") self.logger.info("******** Verifying Delete Nationality********") self.driver = setup self.driver.get(self.baseUrl) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() self.deleteNationality = DeleteNationalityPage(self.driver) time.sleep(3) self.deleteNationality.clickDeleteIcon(self.name) time.sleep(3) self.deleteNationality.confirmDelete() act_title = self.driver.title expected_title = "Nationalities" if act_title == expected_title: self.driver.save_screenshot(".\\screenshots\\" + "test_DeleteNationality.png") self.driver.close() self.logger.info( "******** Delete Nationality Test passed ********") assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_DeleteNationality.png") self.driver.close() self.logger.info( "******** Delete Nationality Test failed ********") assert False
class Test_SearchCustomerByEmail_004: baseURL = ReadConfig.readApplicationURL() username = ReadConfig.readUserEmail() password = ReadConfig.readPassword() logger = LogGeneration.loggen() # Logger @pytest.mark.regression def test_searchCustomerByEmail(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.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() self.logger.info("************* Login Successful **********") self.logger.info( "******* Starting Search Customer By Email **********") self.addCustomer = AddCustomer(self.driver) self.addCustomer.clickCustomers() self.addCustomer.clickSubMenuCustomers() self.logger.info( "************* searching customer by emailID **********") self.searchCustomer = SearchCustomer(self.driver) self.searchCustomer.setEmail("*****@*****.**") self.searchCustomer.clickSearch() time.sleep(5) status = self.searchCustomer.searchCustomerByEmail( "*****@*****.**") self.driver.close() if status: assert True self.logger.info( "*************** TC_SearchCustomerByEmail_004 Finished *********** " )
class Test_004_ViewAddedNationality: baseUrl = "https://staging.riseapp.co.za/lookup/nationalities/list/" username = ReadConfig.getUsername() password = ReadConfig.getPassword() name = ReadConfig.getName() logger = LogGeneration.logGeneration() # Getting logger @pytest.mark.sanity @pytest.mark.regression def test_ViewAddedNationality(self, setup): self.logger.info("******** Test_004_ViewAddedNationality ********") self.driver = setup self.driver.get(self.baseUrl) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() self.view = ViewNationalityPage(self.driver) self.view.clickAddedName(self.name) act_title = self.driver.title expected_title = "View nationality" if act_title == expected_title: self.driver.save_screenshot(".\\screenshots\\" + "test_ViewAddedNationality.png") self.logger.info( "******** View Added Nationality Test passed ********") self.driver.close() assert True else: self.driver.save_screenshot(".\\screenshots\\" + "test_ViewAddedNationality.png") self.driver.close() self.logger.info("******** View Added Nationality failed ********") assert False
class Test005SearchCustomerByName: baseURL = ReadConfig.get_application_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGeneration.log_generation() @pytest.mark.regression def test_search_customer_by_name(self, setup): self.logger.info( "************* Test_005_SearchCustomerByName *************") self.driver = setup self.driver.maximize_window() self.driver.get(self.baseURL) self.logger.info("Entering login credentials") self.login_page = LoginPage(self.driver) self.login_page.set_username(self.username) self.login_page.set_password(self.password) self.login_page.click_login() self.logger.info("Login successful") self.logger.info("Clicking on customer menu") self.customer_page = AddCustomerPage(self.driver) self.customer_page.click_customer_menu() time.sleep(2) self.customer_page.click_customer() self.logger.info("Searching customer by name") self.search_customer = SearchCustomer(self.driver) self.search_customer.set_first_name('John') self.search_customer.set_last_name('Smith') self.search_customer.click_search() time.sleep(3) status = self.search_customer.search_customer_by_name('John Smith') assert True == status self.logger.info("Test_005_SearchCustomerByName finished")
class Test_OO2_DDT_Login: baseURL = ReadConfig.readApplicationURL() message_error = ReadConfig.readErrorMessage() # xml_path = Constants.PARENTDIRECTORY + "\\TestData\\TestData.xml" xml_path = os.path.join(Constants.PARENTDIRECTORY, "TestData", "TestData.xml") logger = LogGeneration.loggen() def test_login(self, setup): self.logger.info( "******************** Test_OO2_DDT_Login ********************") self.logger.info( "******************** Verifying Login DDT Test ********************" ) self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) list_status = [] expected_output = [] login_data_values = ReadXML.readXMLFile(self.xml_path) for credentials in login_data_values: self.username = credentials.get("username") self.password = credentials.get("password") self.output = credentials.get("output") expected_output.append(self.output) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) actual_title = self.driver.title expected_title = Constants.EXPECTED_TITLE if actual_title == expected_title: print( "******************** Valid Login test Passed ********************" ) self.logger.info( "******************** Login test Passed ********************" ) self.lp.clickLogout() list_status.append("Pass") elif actual_title != expected_title: error_returned = self.lp.getErrorMessage() if self.message_error in error_returned: list_status.append("Fail") print( "******************** Invalid Login test Passed ********************" ) self.logger.info( "******************** Invalid Login test Passed ********************" ) time.sleep(5) print(expected_output) print(list_status) print("********** End of Data Driven Test **********") self.driver.close() self.logger.info("********** End of Data Driven Test **********")
class Test002DataDrivenLogin: baseURL = ReadConfig.get_application_url() path = ".//TestData/login_test_data.xlsx" logger = LogGeneration.log_generation() @pytest.mark.regression def test_login_ddt(self, setup): self.logger.info("************* Test_002_DDT_Login *************") self.logger.info("*** Verifying Login DDT test ***") self.driver = setup self.driver.maximize_window() self.driver.get(self.baseURL) # Creating object of LoginPage class self.login_page = LoginPage(self.driver) self.rows = excelUtils.get_row_count(self.path, 'Sheet1') self.cols = excelUtils.get_col_count(self.path, 'Sheet1') status_list = [] for row in range(2, self.rows + 1): self.username = excelUtils.read_data(self.path, 'Sheet1', row, 1) self.password = excelUtils.read_data(self.path, 'Sheet1', row, 2) self.expected = excelUtils.read_data(self.path, 'Sheet1', row, 3) self.login_page.set_username(self.username) self.login_page.set_password(self.password) self.login_page.click_login() time.sleep(2) actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: if self.expected == "Pass": self.logger.info("Scenario passed") self.login_page.click_logout() status_list.append("Pass") elif self.expected == "Fail": self.logger.info("Scenario failed") self.login_page.click_logout() status_list.append("Fail") elif actual_title != expected_title: if self.expected == "Pass": self.logger.info("Scenario failed") status_list.append("Fail") elif self.expected == "Fail": self.logger.info("Scenario passed") status_list.append("Pass") if "Fail" not in status_list: self.logger.info("Data driven login test passed") assert True else: self.logger.info("Data driven login test failed") assert False self.logger.info("*** End of Login DDT test ***")
class Test_003_AddCustomer: baseURL = ReadConfig.readApplicationURL() username = ReadConfig.readUserEmail() password = ReadConfig.readPassword() logger = LogGeneration.loggen() @pytest.mark.sanity def test_login(self, setup): self.logger.info( "******************** Test_003_AddCustomer ********************") self.driver = setup self.driver.get(self.baseURL) self.driver.maximize_window() self.loginPage = LoginPage(self.driver) self.loginPage.setUserName(self.username) self.loginPage.setPassword(self.password) self.loginPage.clickLogin() time.sleep(5) print("********** Login Successful **********") self.addCustomer = AddCustomer(self.driver) self.addCustomer.clickCustomers() self.addCustomer.clickSubMenuCustomers() self.addCustomer.clickAddNewCustomer() time.sleep(5) self.logger.info( "******************** Providing Customer Information ********************" ) print("********** Providing Customer Information **********") self.email = Constants.random_email_generator() self.addCustomer.inputEmail(self.email) self.addCustomer.inputPassword("test123") self.addCustomer.inputFirstName("Bright") self.addCustomer.inputLastName("Brightest") self.addCustomer.selectGender(Constants.MALE) self.addCustomer.inputDateOfBirth("7/05/1985") self.addCustomer.inputCompanyName("NTTData GmbH") self.addCustomer.inputCustomerRoles(Constants.GUESTS) self.addCustomer.selectManagerVendor(Constants.VENDORS_TWO) self.addCustomer.inputAdminContent("This is for testing purposes only") self.driver.save_screenshot(".\\Screenshots\\" + "first_run.png") self.addCustomer.clickSaveButton() self.msg = self.driver.find_element_by_tag_name("body").text # print(self.msg) if 'customer has been added successfully.' in self.msg: assert True self.logger.info("********* Add customer Test Passed *********") else: self.driver.save_screenshot( ".\\Screenshots\\" + "test_addCustomer_scr.png") # Screenshot self.logger.error( "********* Add customer Test Failed ************") assert False self.driver.close() self.logger.info("******* Ending Add customer test **********")