def test_valid_login(self): driver = self.driver self.driver.get("https://opensource-demo.orangehrmlive.com/") login = LoginPage(driver) login.enter_username("Admin") login.enter_password("admin123") login.click_login() hp = HomePage(driver) hp.click_welcome() title = driver.title print("Title-->", title) self.assertEqual(title, "OrangeHRM", "Web page title not matching") hp.click_logout() time.sleep(2)
def test_data_driven_login(self): driver=self.driver self.driver.get("https://opensource-demo.orangehrmlive.com/") logging.getLogger().info("URL Launced") time.sleep(2) rows=get_row_count(self.path,'Sheet1') for r in range(2,rows+1): username=read_data(self.path,"Sheet1",r,1) password=read_data(self.path,"Sheet1",r,2) login = LoginPage(driver) login.enter_username(username) self.logger.info("Username entered") login.enter_password(password) self.logger.info("Password entered") login.click_login() flag=len(driver.find_elements_by_id("welcome")) #print("Flag value",flag) if flag>0: print("Test Case Pass",username,password) logging.getLogger().info("Valid Login") write_data(self.path,'Sheet1',r,3,"Test Pass") hp = HomePage(driver) hp.click_welcome() self.logger.info("Home Page Open") hp.click_logout() time.sleep(2) else: self.logger.error("Login Failed") print("Test Case Fail",username,password) write_data(self.path,'Sheet1',r,3,"Test Fail")