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("******* 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 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_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 *****")