class Test_002_Home: baseURL = ReadConfig.getURL() username = ReadConfig.getUsername() password = ReadConfig.getPassword() logger = LogGenenration.loggen() @pytest.mark.sanity def test_leave(self, setup): self.logger.info("************* Test_002_Home ******************") 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.submit() self.logger.info("*********Login successfull *********") homePage = HomePage(self.driver) homePage.selectLeave() homePage.setFromDate() homePage.selectFromMonth(ReadConfig.getFromMonth()) homePage.selectFromYear(ReadConfig.getFromYear()) homePage.selectFromDate(ReadConfig.getFromDate()) homePage.setToDate() homePage.selectToMonth(ReadConfig.getToMonth()) homePage.selectToYear(ReadConfig.getToYear()) homePage.selectToDate(ReadConfig.getToDate()) homePage.selectRejectedLeaves() homePage.selectUnit(ReadConfig.getUnit()) homePage.search() self.driver.quit()
class Test_001_login: baseURL = ReadConfig.getURL() username = ReadConfig.getUsername() password = ReadConfig.getPassword() logger = LogGenenration.loggen() @pytest.mark.regression def test_login(self, setup): self.logger.info(".................Test_001_home...........") self.logger.info("..........Verifying login............") self.driver = setup self.driver.get(self.baseURL) loginPage = LoginPage(self.driver) loginPage.setUsername(self.username) loginPage.setPassword(self.password) loginPage.submit() user = loginPage.getUser() print("user is.........." + user) if user == "Welcome haresh": self.logger.info("........Successfully logged in..............") assert True self.driver.close() else: self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png") self.logger.error("............login failed..............") self.driver.close() assert False
class Test_002_DDT_login: baseURL = ReadConfig.getURL() path = ".//TestData/loginCreds.xlsx" logger = LogGenenration.loggen() #logging.basicConfig(filename="automation.log", #format="%(asctime)s: %(levelname)s: %(message)s") @pytest.mark.regression 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