def test_DDT_loginPage(self, setup): self.logger.info("******* Test_002__DDT_Login *******") self.logger.info("******** Verifying Login DDT test ******") self.driver = setup self.driver.get(self.baseURL) # Create an Object of LoginPage self.login = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("Number of Rows in the Excel:", self.rows) list_status = [] # Empty list # 2 specifies the 2nd row in the excel sheet # rows+1 specifies the number of rows + the last row for r in range(2, self.rows+1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.userPassword = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.expected = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.login.setUsername(self.user) self.login.setPassword(self.userPassword) self.login.clickLogin() # Getting the title of the page act_title = self.driver.title exp_tile = "Dashboard / nopCommerce administration" # comparing if actual title is equal to expected title if act_title == exp_tile: if self.expected == "Pass": # checking if exp matches xl data "pass" self.logger.info("****** Pass *****") time.sleep(5) self.login.clickLogout(); list_status.append("Pass") elif self.expected == "Fail": # checking if exp matches xl data "pass" self.logger.info("***** failed *****") time.sleep(3) self.login.clickLogout(); list_status.append("Fail") elif act_title != exp_tile: if self.expected == "Pass": self.logger.info("***** failed ******") list_status.append("Fail") elif self.expected == "Fail": self.logger.info("**** Passed ******") list_status.append("Pass") if "Fail" not in list_status: self.logger.info("***** Login DDT test passed ******") self.driver.close() assert True else: self.logger.info("***** Login DDT test failed *****") self.driver.close() assert False self.logger.info("******* End of Login DDT Test ******") self.logger.info("******* Completed TC_LoginDDT_002 *******")
def test_login_ddt(self, setup): self.logger.info("*************** Test_Login_002_DDT *************") self.logger.info( "*************** Verifying the Login test *************") self.driver = setup self.driver.get(self.base_url) self.lp = LoginPage(self.driver) lst_status = [] rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print('No. of rows in the Sheet1: ', rows) for r in range(2, rows + 1): username = ExcelUtils.readData(self.path, "Sheet1", r, 1) password = ExcelUtils.readData(self.path, "Sheet1", r, 2) expected_result = ExcelUtils.readData(self.path, "Sheet1", r, 3) self.lp.setUsername(username) self.lp.setPassword(password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title if act_title == 'Dashboard / nopCommerce administration': if expected_result == "Pass": assert True self.logger.info( "*************** Login test is passed *************") self.lp.clickLogout() lst_status.append("Pass") elif expected_result == "Fail": self.logger.info( "*************** Login test is failed *************") self.lp.clickLogout() lst_status.append("Fail") elif act_title != 'Dashboard / nopCommerce administration': if expected_result == 'Pass': self.logger.info( "*************** Login test is failed *************" ) lst_status.append("Fail") elif expected_result == "Fail": self.logger.info( "*************** Login test is Passed} *************" ) lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("Login DDT is passsed............") self.driver.close() assert True else: self.logger.info("Login DDT is failed............") self.driver.close() assert False self.logger.info(" End of Login DDT test") self.logger.info(" Completed TC_LoginDDT_002")
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.get(self.baseURL) #self.driver.maximize_window() self.lp = Login( self.driver ) # Create an object of class Login to access its action methods self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("No. of rows:", self.rows) list_status = [] # Read the data from excel for r in range(2, self.rows + 1): self.username = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if act_title == exp_title: if self.exp == 'Pass': self.logger.info("******** Passed *********") self.lp.clickLogout() list_status.append("Pass") elif self.exp == 'Fail': self.logger.info("********* Failed *********") self.lp.clickLogout() list_status.append("Fail") elif act_title != exp_title: if self.exp == 'Pass': self.logger.info("********* Failed ***********") list_status.append("Fail") elif self.exp == 'Fail': self.logger.info("********** Passed **********") list_status.append("Pass") print(list_status) if "Fail" not in list_status: self.logger.info("********** Login DDT test Passed **********") self.driver.close() assert True else: self.logger.info("********** Login DDT test Failed **********") self.driver.close() assert False self.logger.info("******* End of Login DDT test ********") self.logger.info("******* Completed Test_002_DDT_Login **********")
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.get(self.baseURL) self.driver.maximize_window() self.lp = LoginPage(self.driver) # Test data 의 행 숫자를 가져옴 self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("Number of rows in Excel:", self.rows) # PASS/FAIL 정보를 넣어줄 빈 리스트 생성 lst_status = [] for r in range(2, self.rows + 1): # Test data에서 엑셀 셀값을 가져옴 self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.driver.get(self.baseURL) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title exp_title = "SK open API" if act_title == exp_title: if self.exp == "Pass": self.logger.info("********** Passed") self.lp.clickLogout() lst_status.append("Pass") elif self.exp == "Fail": self.logger.info("********** Failed") self.lp.clickLogout() lst_status.append("Fail") elif act_title != exp_title: if self.exp == "Pass": self.logger.info("********** Failed") lst_status.append("Fail") elif self.exp == "Fail": self.logger.info("********** Passed") lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("********** Login DDT Test Passed **********") self.driver.close() assert True else: self.logger.info("********** Login DDT Test Failed **********") self.driver.close() assert False self.logger.info("********** End of Login DDT Test **********") self.logger.info("********** Completed TC_LoginDDT_002 **********")
def test_login_ddt(self, setup): self.logger.info("*********Test_02__ddt_Login********") self.logger.info("*******verifying login ddt test**************") self.driver = setup self.driver.get(self.baseURL) self.driver.maximize_window() self.lp = login(self.driver) self.rows = ExcelUtils.getRowcount(self.path, 'Sheet1') print("Number of rows in the excel", self.rows) list_results = [] # empty list for r in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) # read user name from excel self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) # read password from excel self.expected = ExcelUtils.readData( self.path, 'Sheet1', r, 3) # read expected pass/fail from excel self.lp.setUserName(self.user) # get user name self.lp.setPassword(self.password) # get password self.lp.clicklogin() time.sleep(5) act_title = self.driver.title expect_title = "Dashboard / nopCommerce administration" if act_title == expect_title: if self.expected == 'Pass': self.logger.info("*** passed**") self.lp.clicklogout() list_results.append("Pass") elif self.expected == "Fail": self.logger.info("*** Failed**") self.lp.clicklogout() list_results.append("Fail") elif act_title != expect_title: if self.expected == 'Pass': self.logger.info("*** failed**") list_results.append("fail") elif self.expected == "Fail": self.logger.info("*** passed**") list_results.append("pass") if "fail" not in list_results: self.logger.info("Login DDT is passed") self.driver.close() assert True else: self.logger.info("Log in DDT is failed") self.driver.close() assert False self.logger.info("*******End of Login DDT********* ") self.logger.info("********Completed Test_02__ddt_Login*******")
def test_login_ddt(self, setup): self.logger.info("******* Starting Test_002_DDT_Login Test **********") self.logger.info("******* Starting Login DDT Test **********") self.driver = setup self.driver.get(self.baseURL) self.driver.maximize_window() self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print('Number of rows...', self.rows) list_status = [] for r in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if act_title == exp_title: if self.exp == 'Pass': self.logger.info("**** Passed ****") self.lp.clickLogout() list_status.append("Pass") elif self.exp == 'Fail': self.logger.info("**** Failed ****") self.lp.clickLogout() list_status.append("Fail") elif act_title != exp_title: if self.exp == 'Pass': self.logger.info("**** Failed ****") list_status.append("Fail") elif self.exp == 'Fail': self.logger.info("**** Passed ****") list_status.append("Pass") print(list_status) if "Fail" not in list_status: self.logger.info("******* DDT Login test passed **********") self.driver.close() assert True else: self.logger.error("******* DDT Login test failed **********") self.driver.close() assert False self.logger.info("******* End of Login DDT Test **********") self.logger.info( "**************** Completed TC_LoginDDT_002 ************* ")
def test_login_ddt(self, setup): self.logger.info("****Test_002_DDT_Login") self.logger.info("**********verify login_ddt test*************") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("no.of rows in excel", self.rows) lst_status = [] #empty list variable for r in range(2, self.rows + 1): self.user = ExcelUtils.readdata(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readdata(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readdata(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title exp_title = "Dashboard/nopCommerce administration" if act_title == exp_title: if self.exp == "Pass": self.logger.info("******passed") self.lp.clickLogout() lst_status.append("pass") elif self.exp == "fail": self.logger.info("*********failed*****") self.lp.clickLogout() lst_status.append("fail") elif act_title != exp_title: if self.exp == 'Pass': self.logger.info("********failed*****") lst_status.append("Fail") elif self.exp == 'fail': self.logger.info("*********passed****") lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("**********login ddt test passed****") self.driver.close() assert True else: self.logger.info("**********login ddt test failed****") self.driver.close() assert False self.logger.info("end of login ddt test") self.logger.info("completed test_002_login_ddt")
def test_login_ddt(self, setup): self.logger.info("*********test no. 1***********") self.logger.info("*********verifying Login DDT test***********") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'sheet1') print("Number of Row: ", self.rows) lst_status = [] #empty list vars for row in range(2, self.rows + 1): self.username = ExcelUtils.readData(self.path, 'sheet1', row, 1) self.password = ExcelUtils.readData(self.path, 'sheet1', row, 2) self.exp = ExcelUtils.readData(self.path, 'sheet1', row, 3) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if act_title == exp_title: if self.exp == "Pass": self.logger.info("***Passed***") self.lp.clickLogout() lst_status.append("Pass") elif self.exp == "Fail": self.logger.info("**Failed***") self.lp.clickLogout() lst_status.append("Fail") elif act_title != exp_title: if self.exp == "Pass": self.logger.info("***Failed***") lst_status.append("Fail") elif self.exp == "Fail": self.logger.info("***Passed***") lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("***Login DDT test has passed***") self.driver.close() assert True else: self.logger.info("***Login DDT test has failed***") self.driver.close() assert False self.logger.info(lst_status) self.logger.info("end of test")
def test_loginPageTitle_ddt(self, setup): self.logger.info( "******* Starting Test Login Page DDT Test **********") self.logger.info( "******* Starting Test 002 DDT LoginPage Title Test **********") self.driver = setup self.driver.maximize_window() self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print('Number of Rows: ', self.rows) for r in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.status = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUsername(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) act_title = self.driver.title if act_title == 'Dashboard / nopCommerce administration': if self.status == 'Pass': self.logger.info("*** Passed ***") self.lp.clickLogout() self.lst_status.append("Pass") elif self.status == 'Fail': self.logger.info("*** Failed ***") self.lp.clickLogout() self.lst_status.append("Fail") elif act_title != 'Dashboard / nopCommerce administration': if self.status == 'Pass': self.logger.info("*** Failed ***") self.lst_status.append("Fail") elif self.status == 'Fail': self.logger.info("*** Passed ***") self.lst_status.append("Pass") if "Fail" not in self.lst_status: self.logger.info("***** Login DDT Passed *****") self.driver.close() assert True else: self.logger.info("***** Login DDT Failed *****") self.driver.close() assert False self.logger.info("******* Ending Test Login Page DDT Test **********") self.logger.info( "******* Completed Test 002 DDT LoginPage Title Test **********")
def test_login_ddt(self, setup): logging.info(".................Test_002_DDT_login...........") self.logger.info("..........Verifying login............") self.driver = setup self.driver.get(self.baseURL) loginPage = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') self.columns = ExcelUtils.getColumnCount(self.path, 'Sheet1') login_status = [] for i in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', i, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', i, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', i, 3) loginPage.setUsername(self.user) loginPage.setPassword(self.password) loginPage.submit() time.sleep(2) dashboard_url = self.driver.current_url if dashboard_url == "https://opensource-demo.orangehrmlive.com/index.php/dashboard": self.logger.info("........Successfully logged in for user " + self.user) if self.exp == "pass": loginPage.clickLogout() login_status.append("Pass") elif self.exp == "fail": self.logger.info("........Failed logged in for user " + self.user) loginPage.clickLogout() login_status.append("Fail") else: if self.exp == "pass": self.logger.info("........Failed logged in for user " + self.user) login_status.append("Fail") elif self.exp == "fail": self.logger.info("........Failed logged in for user " + self.user + " but tc passed") login_status.append("Pass") if "Fail" not in login_status: self.logger.info("***Login DDT test passed*******") self.driver.close() assert True else: self.logger.info("***Login DDT test failed*******") self.driver.close() assert False
def test_login(self,setup): self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows= ExcelUtils.getRowCount(self.path, 'Sheet1') self.logger.info("************TEST_002_Login_DDT************") self.logger.info("*****Verifying Login using DDT*****") for r in range(2,self.rows+1): self.user = ExcelUtils.readData(self.path,'Sheet1',r,1) self.password = ExcelUtils.readData(self.path,'Sheet1',r,2) self.exp = ExcelUtils.readData(self.path,'Sheet1',r,3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(4) act_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if act_title == exp_title: if self.exp == "Pass": self.logger.info("*****Passed*****") self.lp.clickLogout() self.lst_status.append("Pass") elif self.exp == "Fail": self.logger.info("*****Failed*****") self.lp.clickLogout() self.lst_status.append("Fail") elif act_title != exp_title: if self.exp == "Pass": self.logger.info("*****Failed*****") self.lst_status.append("Fail") elif self.exp == "Fail": self.logger.info("*****Passed*****") self.lst_status.append("Pass") if "Fail" not in self.lst_status: self.logger.info("***** Login DDT test passed *****") self.driver.close() assert True else: self.logger.info("***** Login DDT test failed *****") self.driver.close() assert False self.logger.info("*********** Completed TEST_002_Login_DDT ***********") self.logger.info("#### End of TEST_002_Login_DDT ####")
def test_Login_ddt(self, setup): self.log.info("**********Test_002_DDT_Login****************") self.log.info("************Verifying Login DDT test*************") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("No. of rows in excel file are: ", self.rows) lst_status = [] for r in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.password = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) actual_title = self.driver.title exp_title = "Dashboard / nopCommerce administration" if actual_title == exp_title: if self.exp == "Pass": self.log.info("********passed*************") self.lp.clickLogout() lst_status.append("Pass") elif self.exp == "Fail": self.log.info("**********Failed***********") self.lp.clickLogout() lst_status.append("Fail") elif actual_title != exp_title: if self.exp == "Pass": self.log.info("********Failed*************") lst_status.append("Fail") elif self.exp == "Fail": self.log.info("**********Passed***********") lst_status.append("Pass") if 'Fail' not in lst_status: self.log.info("*********Login DDT Test is passed**********") self.driver.close() assert True else: self.log.info("*********Login DDT Test is failed**********") self.driver.close() assert False self.log.info("*********End of Login DDT Test**********") self.log.info( "*********Completed Test_002_DDT_Login test case**********")
def getExcelRecord(self, rows, columns): excel_data = [] for r in range(rows, columns): self.add_user_username = ExcelUtils.readData( self.path, 'Add User', r, 1) self.add_user_email = ExcelUtils.readData(self.path, 'Add User', r, 2) self.add_user_role = ExcelUtils.readData(self.path, 'Add User', r, 3) self.add_user_accessTo = ExcelUtils.readData( self.path, 'Add User', r, 4) excel_data.append(self.add_user_username) excel_data.append(self.add_user_email) excel_data.append(self.add_user_role) excel_data.append(self.add_user_accessTo) return excel_data
def getExcelDeleteData(self, rows, columns): excel_data = [] for r in range(rows, columns): self.add_user_username = ExcelUtils.readData( self.path, 'Add User', r, 1) excel_data.append(self.add_user_username) return excel_data
def test_login_ddt(self, setup): self.logger.info("************Test_002_DDT_Login***********") self.logger.info("************Verify Login ************") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, 'Sheet1') print("Number of row i a excel", self.rows) lst_status = [] for r in range(2, self.rows + 1): self.user = ExcelUtils.readData(self.path, 'Sheet1', r, 1) self.passw = ExcelUtils.readData(self.path, 'Sheet1', r, 2) self.exp = ExcelUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.passw) self.lp.clickLogin() time.sleep(5) title = self.driver.title if title == "Dashboard / nopCommerce administration": if self.exp == "Pass": self.logger.info("***Passed") self.lp.clickLogout() lst_status.append("Pass") elif self.exp == "Fail": self.logger.info("***Fail") self.lp.clickLogout() lst_status.append("Fail") elif title != "Dashboard / nopCommerce administration": if self.exp == "Pass": self.logger.info("***Fail") lst_status.append("Fail") elif self.exp == "Fail": self.logger.info("***Passed") lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("*******Login DDT Passed******") self.driver.close() assert True else: self.logger.info("*******Login DDT Failed******") self.driver.close() assert True self.logger.info("*********End of Login DDT Test***********")
def test_verify_login_DDT(self, setup): self.logger = LogGen.loggen() # column = ExcelUtils.get_columns_count(self.path) row = ExcelUtils.get_rows_count(self.path) self.logger.info("test_verify_login_DDT testcase has started") self.driver = setup self.lp = Login(self.driver) list_result = [] for i in range(2, row + 1): username = ExcelUtils.read_excel_file_data(self.path, i, 1) password = ExcelUtils.read_excel_file_data(self.path, i, 2) expected_result = ExcelUtils.read_excel_file_data(self.path, i, 3) self.driver.get(self.base_url) self.lp.set_username(username) self.lp.set_password(password) self.lp.click_login() time.sleep(2) if self.driver.title == 'Dashboard / nopCommerce administration': if expected_result == 'Pass': self.logger.info("Passed") list_result.append('Pass') assert True elif expected_result == 'Fail': self.logger.info("Failed") list_result.append('Fail') assert True elif self.driver.title != 'Dashboard / nopCommerce administration': if expected_result == 'Pass': self.logger.info("Failed") list_result.append('Fail') assert False elif expected_result == 'Fail': self.logger.info("Passed") list_result.append('Pass') assert True try: if 'Fail' not in list_result: self.logger.info("TEST CASE PASSED") else: self.logger.info("TEST CASE FAILED") finally: self.driver.close() self.logger.info( "***********Test case test_verify_login_DDT has completed********")
def test_admin_login_add_user_user_exist_error_msg(self, setup): self.starting_row_num = 5 self.ending_row_num = 8 self.logger.info( "******Testing admin login user exist msg checking...******") self.driver = setup self.al = AdminLogin(self.driver) self.al.adminLogin() self.al.clickAuthentication() self.al.clickAddUser() self.al.clickSubmit() status = [] # Reading the data from excel file for r in range(self.starting_row_num, self.ending_row_num): self.add_user_username = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 1) self.add_user_email = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 2) self.add_user_role = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 3) self.add_user_accessTo = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 4) self.add_user_password = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 5) self.add_user_exp = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 6) self.al.setAddUserUserName(self.add_user_username) self.al.setAddUserEmail(self.add_user_email) self.al.setAdduserSelectRole(self.add_user_role) self.al.setAdduserSelectAccessTo(self.add_user_accessTo) self.al.setAddUserPassword(self.add_user_password) self.al.clickSubmit() time.sleep(2) act_title = self.al.getAddUserSuccessMsg() exp_title = "User exists with that name. Please create with different user" self.driver.refresh() if act_title == exp_title: if self.add_user_exp == "Pass": status.append("Pass") elif self.add_user_exp == "Fail": status.append("Fail") elif act_title != exp_title: if self.add_user_exp == "Pass": status.append("Fail") elif self.add_user_exp == "Fail": status.append("Pass") if "Fail" not in status: self.logger.info( "******Testing admin login user exist msg checking completed...******" ) self.driver.close() assert True else: self.logger.info( "******Testing admin login user exist msg checking failed...******" ) self.driver.close() assert False
def test_admin_login_userlist_edit_users(self, setup): self.logger.info("******Testing admin login edit user's started******") self.starting_row_num = 8 self.ending_row_num = 9 self.driver = setup self.al = AdminLogin(self.driver) self.al.adminLogin() self.al.clickAuthentication() self.al.clickAddUser() # Reading the data from excel file for r in range(self.starting_row_num, self.ending_row_num): self.add_user_username = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 1) self.add_user_email = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 2) self.add_user_role = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 3) self.add_user_accessTo = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 4) self.add_user_password = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 5) self.add_user_exp = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 6) self.al.setAddUserUserName(self.add_user_username) self.al.setAddUserEmail(self.add_user_email) self.al.setAdduserSelectRole(self.add_user_role) self.al.setAdduserSelectAccessTo(self.add_user_accessTo) self.al.setAddUserPassword(self.add_user_password) self.al.clickSubmit() time.sleep(2) self.driver.refresh() self.al.clickAuthentication() self.al.clickUserList() time.sleep(5) user_list = self.al.getUsersList() update_list = self.al.getExcelDeleteData(8, 9) row_num = [] for x in update_list: for y in user_list: if y[1] == x: row_num.append(y[0]) excel_record = self.al.getExcelRecord(8, 9) self.test_status = self.al.clickUpdateUser(row_num, excel_record) if "Fail" not in self.test_status: self.logger.info( "******Testing admin login update user's successfully created******" ) self.driver.close() assert True, "Edit user successful for admin,ceo and manager" else: self.logger.info( "******Testing admin login update user's failed******") self.driver.close() assert False, "Edit user Failed"
def test_admin_login_add_user_admin_ceo_manager(self, setup): self.starting_row_num = 5 self.ending_row_num = 8 self.logger.info( "******Testing admin login add users(admin,ceo,manager) started******" ) self.driver = setup self.al = AdminLogin(self.driver) self.al.adminLogin() self.al.clickAuthentication() self.al.clickAddUser() self.al.clickSubmit() status = [] # Reading the data from excel file for r in range(self.starting_row_num, self.ending_row_num): self.add_user_username = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 1) self.add_user_email = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 2) self.add_user_role = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 3) self.add_user_accessTo = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 4) self.add_user_password = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 5) self.add_user_exp = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 6) self.al.setAddUserUserName(self.add_user_username) self.al.setAddUserEmail(self.add_user_email) self.al.setAdduserSelectRole(self.add_user_role) self.al.setAdduserSelectAccessTo(self.add_user_accessTo) self.al.setAddUserPassword(self.add_user_password) self.al.clickSubmit() time.sleep(1) act_title = self.al.getAddUserSuccessMsg() exp_title = "User created successfully" if act_title == exp_title: if self.add_user_exp == "Pass": status.append("Pass") elif self.add_user_exp == "Fail": status.append("Fail") elif act_title != exp_title: if self.add_user_exp == "Pass": status.append("Fail") elif self.add_user_exp == "Fail": status.append("Pass") if "Fail" not in status: self.logger.info( "******Testing admin login add users(admin,ceo,manager) completed******" ) self.driver.close() assert True else: self.driver.save_screenshot("../Screenshots/" + "test_addUsers(admin,ceo,manger).png") self.logger.info( "******Testing admin login add users(admin,ceo,manager) failed******" ) self.driver.close() assert False
def test_loginPage_ddt(self, setup): self.logger.info("***** Test_003_DDT_Login Started *****") self.driver = setup time.sleep(5) self.driver.get(self.baseURL) self.driver.maximize_window() time.sleep(5) # create variable self.cap = createAccount(self.driver) self.cap.clickSignin() # create new variable time.sleep(5) self.lp = LoginPage(self.driver) # read data from excel file self.rows = ExcelUtils.getRowCount(self.path, "Sheet1") # empty list variable for exp values lst_status = [] time.sleep(5) print('Number of Rows:', self.rows) for row in range(2, self.rows + 1): # read email(column 1) self.email = ExcelUtils.readData(self.path, 'Sheet1', row, 1) # read password(column 2) self.password = ExcelUtils.readData(self.path, 'Sheet1', row, 2) # read exp(column 3) self.exp = ExcelUtils.readData(self.path, 'Sheet1', row, 3) # Get the email and password from excel self.lp.setEmail(self.email) self.lp.setPassword(self.password) self.lp.clickSign() self.logger.info("***** Login Success *****") time.sleep(5) # validate title of the page act_title = self.driver.title exp_title = "My account - My Store" if exp_title == act_title: # validate exp value from excel if self.exp == 'Pass': self.logger.info("***** Login Passed *****") self.lp.clickSignout() lst_status.append('Pass') elif self.exp == 'Fail': self.logger.error("***** Failed *****") self.lp.clickSignout() lst_status.append("Fail") elif act_title != exp_title: if self.exp == 'Pass': self.logger.error("***** Login Failed *****") lst_status.append('Failed') elif self.exp == 'Fail': self.logger.info("***** Passed *****") lst_status.append("Pass") # for failed exp values if "Fail" not in lst_status: self.logger.info("***** Login Passed *****") self.driver.close() assert True else: self.logger.error("***** Login Failed *****") self.driver.close() assert False self.logger.info("***** Test_003_DDT_Login Completed *****")
def test_login(self, setup): self.driver = setup self.logger.info("*********** Starting TEST_002_Login_DDT ***********") self.logger.info( "************ Opening OrangeHRM Application ************") self.driver.get(self.baseURL) self.driver.maximize_window() self.logger.info( "***** Checking the Login Functionality with multiple users *****") self.lp = LoginPage(self.driver) self.rows = ExcelUtils.getRowCount(self.path, "Sheet1") for r in range(2, self.rows + 1): self.logger.info("***** Entering " + str(r - 1) + " UserName *****") self.lp.setUserName(ExcelUtils.readData(self.path, "Sheet1", r, 1)) self.logger.info("***** Entering Password *****") self.lp.setPassword(ExcelUtils.readData(self.path, "Sheet1", r, 2)) self.logger.info("***** Clicking on Login Button *****") self.lp.clickLogin() time.sleep(2) act_url = self.driver.current_url self.expected_condition = ExcelUtils.readData( self.path, "Sheet1", r, 3) if act_url == "https://opensource-demo.orangehrmlive.com/index.php/dashboard": if self.expected_condition == "Pass": self.logger.info( "***** Expected Condition met successfully *****") self.lst_status.append("Pass") self.lp.clickLogout() elif self.expected_condition == "Fail": self.logger.info("***** Expected Condition not met *****") self.lst_status.append("Fail") self.lp.clickLogout() elif act_url != "https://opensource-demo.orangehrmlive.com/index.php/dashboard": if self.expected_condition == "Pass": self.logger.info("***** Failed *****") self.driver.save_screenshot( "C:\\Users\\Salim\\eclipse-workspace\\orangeHRM\\Screenshots\\" + "LoginFailed" + str(r - 1) + ".png") self.logger.info( "***** Login Failed, Please check the Screenshots Folder *****" ) self.lst_status.append("Fail") elif self.expected_condition == "Fail": self.logger.info( "***** Expected Condition met successfully *****") self.lst_status.append("Pass") if "Fail" not in self.lst_status: self.logger.info("***** Login DDT test passed *****") self.driver.close() self.logger.info("***** Closing Browser *****") assert True else: self.logger.info("***** Login DDT test failed *****") self.logger.info("***** Closing Browser *****") self.driver.close() assert False self.logger.info( "*********** Completed TEST_002_Login_DDT ***********") self.logger.info("***** End of TEST_002_Login_DDT *****")
def test_admin_login_userlist_delete(self, setup): self.delete_user_list = [] self.starting_row_num = 9 self.ending_row_num = 10 self.logger.info( "******Testing admin login adduser delete option started******") self.driver = setup self.al = AdminLogin(self.driver) self.al.adminLogin() self.al.clickAuthentication() self.al.clickAddUser() # Getting the data from excel file and creating the new user in the atria add user page for r in range(self.starting_row_num, self.ending_row_num): self.add_user_username = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 1) self.delete_user_list.append(self.add_user_username) self.add_user_email = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 2) self.add_user_role = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 3) self.add_user_accessTo = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 4) self.add_user_password = ExcelUtils.readData( self.al.getExcelPath(), 'Add User', r, 5) self.add_user_exp = ExcelUtils.readData(self.al.getExcelPath(), 'Add User', r, 6) self.al.setAddUserUserName(self.add_user_username) self.al.setAddUserEmail(self.add_user_email) self.al.setAdduserSelectRole(self.add_user_role) self.al.setAdduserSelectAccessTo(self.add_user_accessTo) self.al.setAddUserPassword(self.add_user_password) self.al.clickSubmit() time.sleep(2) self.al.clickAuthentication() self.al.clickUserList() time.sleep(2) user_list = self.al.getUsersList() delete_id = [] for delete_user in self.delete_user_list: for user in user_list: if user[1] == delete_user: delete_id.append(user[0]) self.al.clickAddUserDeleteOption(delete_id) time.sleep(10) user_list_after_delete = self.al.getUsersList() get_deleted_user_list = self.delete_user_list self.status = False # Checking whether deleted user list still present in the userlist page for deleted_user in get_deleted_user_list: for user in user_list_after_delete: if user[1] == deleted_user: self.status = True # if user found making status to true if self.status == False: self.logger.info( "******Testing admin login adduser delete option completed******" ) assert True, "User deleted successfully" self.driver.close() else: self.driver.save_screenshot("../Screenshots/" + "test_admin_login_delete_option.png") self.logger.info( "******Testing admin login adduser delete option failed******") self.driver.close() assert False, "User not deleted"