def test_Loginpage_DDT(self, setup): #self.driver = webdriver.Chrome(ChromeDriverManager().install()) self.logger.info("************Test_002_DDT_Login************") self.logger.info( "************test_Loginpage_DDT veriying*************") self.driver = setup self.driver.get(self.baseUrl) self.lp = Login(self.driver) self.rows = XLUtils.getRowCount(self.path, 'Sheet1') print("numbers of rows", self.rows) lst_status = [] #empty list for r in range(2, self.rows + 1): self.user = XLUtils.readData(self.path, 'Sheet1', r, 1) self.password = XLUtils.readData(self.path, 'Sheet1', r, 2) self.exp = XLUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.Click_Login() time.sleep(5) act_title = self.driver.title print(act_title) exp_title = "Dashboard / nopCommerce administration" print(exp_title) if act_title == exp_title: if self.exp == "Pass": self.logger.info("*******condition passed*******") print("at=et") self.lp.Click_Logout() lst_status.append("Pass") elif self.exp == "Fail": self.logger.info("*******condition failed*******") self.lp.Click_Logout() lst_status.append("Fail") elif act_title != exp_title: if self.exp == "Pass": self.logger.info("*******condition failed*******") #self.lp.Click_Logout() lst_status.append("Fail") elif self.exp == "Fail": self.logger.info("*******condition passed*******") #self.lp.Click_Logout() lst_status.append("Pass") if "Fail" not in lst_status: self.logger.info("******Login DDT test passed********") print("Login DDT test passed") self.driver.close() assert True else: self.logger.info("*********Login DDT test failed***************") print("Login DDT test failed") self.driver.close() assert False self.logger.info("**********End of Login DDT test****************")
def test_login(self, setup): self.logger.info("**Test_002_DDT_Login**") self.logger.info("**Verify The Login DDT function**") self.driver = setup self.driver.get(self.baseurl) self.lp = LoginPage(self.driver) self.rows = XLUtils.getRowCount(self.path, 'Sheet1') # List variable to capture to results of the test lst_status = [] # Empty list variable for r in range(2, self.rows + 1): self.username = XLUtils.readData(self.path, 'Sheet1', r, 1) self.password = XLUtils.readData(self.path, 'Sheet1', r, 2) self.expected = XLUtils.readData(self.path, 'Sheet1', r, 3) self.lp.setUserName(self.username) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(2) act_title = self.driver.title exp_tile = "Dashboard / nopCommerce administration" if act_title == exp_tile: if self.expected == "Pass": self.logger.info("***Test Passed***" + self.username) self.lp.clickLogout() lst_status.append("Pass") elif self.expected == "Fail": self.logger.error("***Test Failed***" + self.username) self.lp.clickLogout() lst_status.append("Fail") elif act_title != exp_tile: if self.expected == "Pass": self.logger.error("***Test Failed***" + self.username) lst_status.append("Fail") elif self.expected == "Fail": self.logger.info("***Test Passed***" + self.username) 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.error("***Login DDT Test Failed***") self.driver.close() assert False self.logger.info("***End of DDT Test**") self.logger.info("***Completed the Test ***")
def test_Login_DDT(self, setup): self.logger.info("*********** Test_002_DDT_Login ***********") self.logger.info("*********** Verifying Login Title ***********") self.driver = setup self.driver.get(self.baseURL) self.lp = Login(self.driver) self.rows = XLUtils.getRowCount(self.path,"Sheet1") print("Number of rows in excel:", self.rows) lst_status = [] # Empty ist variable for r in range(2,self.rows + 1): self.username = XLUtils.readData(self.path,"Sheet1",r,1) self.password = XLUtils.readData(self.path, "Sheet1", r, 2) self.expected = XLUtils.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.expected == "Pass": self.logger.info("*********** Login Title test is passed ***********") self.lp.clickLogout() lst_status.append("Pass") else: self.driver.save_screenshot("C:\\Users\\durve\\PycharmProjects\\PytestFramework\\Screenshots\\"+ "test_Login.png") self.logger.error("*********** Login Title test is failed ***********") lst_status.append("Fail") self.lp.clickLogout() else: if self.expected == "Fail": self.logger.info("*********** Login Title test is passed ***********") lst_status.append("Pass") else: self.driver.save_screenshot("C:\\Users\\durve\\PycharmProjects\\PytestFramework\\Screenshots\\"+ "test_Login.png") self.logger.error("*********** Login Title test is failed ***********") lst_status.append("Fail") if "Fail" not in lst_status: self.logger.error("*********** Test Login DDT testcase is passed ***********") self.driver.close() assert True else: self.logger.error("*********** Test Login DDT testcase is failed ***********") self.driver.close() assert False self.logger.info("************End of Login Test CAse DDT**************") self.logger.info('**************Completed TC_LoginDDT_002**************')
def getAllUsers(self): rowsCount = XLUtils.getRowCount(Env.dataPath, 'usersData') for r in range(2, rowsCount + 1): currentUser = User() currentUser.name = XLUtils.readData(Env.dataPath, "usersData", r, 1) book = UsersBook() book.ISBNnumber = XLUtils.readData(Env.dataPath, "usersData", r, 2) book.checkoutDate = XLUtils.readData(Env.dataPath, "usersData", r, 3) currentUser.userExistingBooks.append(book) if currentUser.name in self.usersDictionary.keys(): self.usersDictionary[currentUser.name].userExistingBooks.append(book) else: self.usersDictionary[currentUser.name] = currentUser
def test_loginPage(self, setup): self.logger.info("**************** Verifying login test *********") self.driver = setup self.driver.get(self.baseURL) lp = login(self.driver) path = ".//TestData/My_data.xlsx" rows = XLUtils.getRowCount(path, "Sheet1") for r in range(2, rows+1): self.username = XLUtils.readData(path, "Sheet1", r, 1) self.password = XLUtils.readData(path,"Sheet1", r, 2) self.exp = XLUtils.readData(path,"Sheet1", r, 3) lst_status = [] lp.setUserName(self.username) lp.setPassword(self.password) lp.click_login() act_title = self.driver.title if act_title == "Dashboard / nopCommerce administration": if self.exp == "Pass": self.logger.info("**************** login test passed *********") lp.click_logout() lst_status.append("Pass") elif self.exp=="Fail": self.logger.error("**************** login test user2 failed *********") lst_status.append("Fail") elif act_title != "Dashboard / nopCommerce administration": if self.exp == "Pass": self.logger.info("**************** login user 3 failed test test passed *********") lst_status.append("Fail") elif self.exp=="Fail": self.logger.error("**************** login user 4 failed test pass *********") lst_status.append("Pass") if "Pass" not in lst_status: self.logger.error("************* login test ddt is passed ***************") self.driver.close() assert True else: self.logger.error("************* login test ddt is failed ***************") self.driver.close() assert False self.logger.error("************* login test ddt passes ***************") self.logger.error("************* completed TC_002 ***************")
def test_login_ddt(self, setup): self.log.info("********* Test_001_ddt_Login ********") self.log.info("********* Verifying Login Test ********") self.driver = setup self.driver.get(self.baseURL) self.lp = LoginPage(self.driver) lst_status = [] self.rows = XLUtils.getRowCount(self.path, "Sheet1") for r in range(2, self.rows + 1): self.user = XLUtils.readData(self.path, "Sheet1", r, 1) self.password = XLUtils.readData(self.path, "Sheet1", r, 2) self.exp = XLUtils.readData(self.path, "Sheet1", r, 3) self.lp.setUserName(self.user) self.lp.setPassword(self.password) self.lp.clickLogin() time.sleep(5) page_title = self.driver.title if page_title == "Dashboard / nopCommerce administration": if self.exp == "Pass": self.lp.clickLogout() self.log.info("********* Passed ********") lst_status.append("Pass") elif self.exp == "Fail": self.log.info("********* Failed ********") lst_status.append("Fail") elif page_title != "Dashboard / nopCommerce administration": if self.exp == "Pass": self.log.info("********* Failed ********") lst_status.append("Fail") elif self.exp == "Fail": self.log.info("********* Passed ********") if "Fail" not in lst_status: self.log.info("Login DDT Test Passed") self.driver.close() assert True else: self.log.info("*********** Login DDT Test Failed ***********") self.driver.close() assert False self.log.info("*********** End of DDT Test ************") self.log.info("*********** Test_002_DDT_Login Completed ************")
def getAllBooks(self): rowsCount = XLUtils.getRowCount(Env.dataPath, 'booksData') for r in range(2, rowsCount + 1): currentBook = Book() currentBook.ISBNnumber = XLUtils.readData(Env.dataPath, "booksData", r, 1) currentBook.title = XLUtils.readData(Env.dataPath, "booksData", r, 2) currentBook.pages = XLUtils.readData(Env.dataPath, "booksData", r, 3) currentBook.count = XLUtils.readData(Env.dataPath, "booksData", r, 4) currentBook.availableCount = XLUtils.readData( Env.dataPath, "booksData", r, 5) temp = str(XLUtils.readData(Env.dataPath, "booksData", r, 6)) currentBook.subscribersNames = temp.split(sep=", ") temp = str(XLUtils.readData(Env.dataPath, "booksData", r, 7)) currentBook.reservedFrom = temp.split(sep=", ") self.booksDictionary[str(currentBook.ISBNnumber)] = currentBook
def test_login_DDT(self, setup): self.LO.info("*****Test_ddt_002****") self.LO.info("****Verify Login page****") self.driver = setup self.driver.get(self.baseURL) self.LP = Loginpage(self.driver) self.rows = XLUtils.getRowCount(self.path, sheetName="Sheet1") self.columns = XLUtils.getColumnCount(self.path, sheetName="Sheet1") print(" No of rows in excel:", self.rows) print("No of columns in excel", self.columns) Lis_status = [] #print(Lis_status) for r in range(2, self.rows + 1): self.username = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=1) self.password = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=2) self.expected = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=3) self.output = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=4) self.LP.setUserName(self.username) self.LP.setPassword(self.password) self.LP.clickLogin() time.sleep(10) actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: if self.expected == "pass": self.LO.info("***Passed") self.LP.clicklogout() time.sleep(3) Lis_status.append("Pass") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Pass") elif self.expected == "fail": self.LO.info("***Failed") self.LP.clicklogout() time.sleep(10) Lis_status.append("Fail") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Fail") elif actual_title != expected_title: if self.expected == "pass": self.LO.info("****Failed") Lis_status.append("Fail") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Fail") time.sleep(10) elif self.expected == "fail": self.LO.info("****Passed") Lis_status.append("Pass") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Pass") time.sleep(5) if "Fail" not in Lis_status: self.LO.info("The DDT test is passed") self.driver.close() assert True else: self.LO.info("the DDT test is failed") self.driver.close() assert False self.LO.info("End of Login_DDT test") self.LO.info("complete the test case for data driven")