class Test_002_DDT_Login(): baseURL = ReadConfig.get_base_url() path = ".//TestData/LoginData.xlsx" logger = LogGen.loggen() # Logger @pytest.mark.regression 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 = xl.getRowCount(self.path, 'Sheet1') print('Number of rows...',self.rows) lst_status=[] for r in range(2,self.rows+1): self.user=xl.readData(self.path,'Sheet1',r,1) self.password = xl.readData(self.path, 'Sheet1', r, 2) self.exp = xl.readData(self.path, 'Sheet1', r, 3) self.lp.set_login_username(self.user) self.lp.set_login_password(self.password) self.lp.click_login_button() 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.click_logout_button() lst_status.append("Pass") elif self.exp=='Fail': self.logger.info("**** failed ****") self.lp.click_logout_button() 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") print(lst_status) if "Fail" not in lst_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_in(self): self.logger.info("*************Test_Login _in***************") self.logger.info("*************Verifying Login In***************") self.loginPage = LoginPage(self.driver) self.loginPage.do_login(self.adminEmail, self.password) self.driver.save_screenshot(".\\Screenshots\\" + "test_Login.png") self.logger.info("*************Pass Login in test***************") allure.attach(self.driver.get_screenshot_as_png(), name="Test login screen", attachment_type=AttachmentType.PNG)
def test_click_here(self): self.logger = LogGen.loggen() self.logger.info("*************Test_Login***************") self.logger.info("*************verifying_click_here***************") self.loginPage = LoginPage(self.driver) flag = self.loginPage.is_forget_password_link_exist() assert flag self.driver.save_screenshot(".\\Screenshots\\" + "test_click_here.png") self.logger.info("*************Pass_click_here***************") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Click here screen", attachment_type=AttachmentType.PNG)
def test_inventory_item_links(self, standard_user_cred): login_page = LoginPage(self.driver) inventory = Inventory(self.driver) curl = self.driver.current_url if curl == "https://www.saucedemo.com/": login_page.setUsername(standard_user_cred[0]) login_page.setPassword((standard_user_cred[1])) login_page.clickLoginButton() elif curl != "https://www.saucedemo.com/inventory.html": inventory.clickBurgerButton() inventory.clickAllItems() links = inventory.getItemLinks() for i in range(len(links)): els = self.driver.find_elements( By.CSS_SELECTOR, "div.inventory_item > div.inventory_item_description > div.inventory_item_label > a" ) els[i].click() if links[i] == self.driver.current_url: self.log.info( f":{self.__class__.test_inventory_item_links.__name__}: {[*standard_user_cred]} :: TEST PASSED" ) self.driver.back() assert True else: self.log.info( f":{self.__class__.test_inventory_item_links.__name__}: {[*standard_user_cred]} :: TEST FAILED" ) self.driver.back() assert False
def test_add_customer(self, setup): self.driver = setup self.driver.get(self.base_url) self.driver.maximize_window() login_page_obj = LoginPage(self.driver) login_page_obj.set_login_username(self.username) login_page_obj.set_login_password(self.password) login_page_obj.click_login_button() self.customer_page_obj = AddCustomer(self.driver) self.customer_page_obj.click_menu_link_customers() self.customer_page_obj.click_menu_item_link_customers() actual_title = self.driver.title if actual_title == "Customers / nopCommerce administration": assert True self.driver.close() self.logger.info("****** Add Customer Passed ******") else: self.driver.save_screenshot(".\\Screenshots\\" + "Test_003_Add_Customer.png") self.driver.close() self.logger.info("********* Add Customer FAILED *****") assert False
def test_inventory_cart_counter(self, standard_user_cred): login_page = LoginPage(self.driver) inventory = Inventory(self.driver) curl = self.driver.current_url if curl == "https://www.saucedemo.com/": login_page.setUsername(standard_user_cred[0]) login_page.setPassword((standard_user_cred[1])) login_page.clickLoginButton() elif curl != "https://www.saucedemo.com/inventory.html": inventory.clickBurgerButton() inventory.clickAllItems() counter = inventory.clickAllCartButtons() cart_counter = inventory.getCartCounter() if counter == cart_counter: self.log.info( f":{self.__class__.test_inventory_cart_counter.__name__}: {[*standard_user_cred]} :: TEST PASSED" ) assert True else: self.log.info( f":{self.__class__.test_inventory_cart_counter.__name__}: {[*standard_user_cred]} :: TEST FAILED" ) assert False
def test_login_ddt(self): self.driver.get(self.baseURL) self.loginPage = LoginPage(self.driver) self.logger.info("******* Starting Test_DDT_Login Test **********") self.logger.info("******* Starting Login DDT Test **********") self.rows = XLUtils.getRowCount(self.path, 'Sheet1') print("number of rows i a excel: ", self.rows) lst_status = [] #empty list self.logger.info("******* Reading data from excel **********") 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.status = XLUtils.readData(self.path, 'Sheet1', r, 3) self.loginPage.do_login(self.user, self.password) if self.status == "True": if self.driver.title == self.homePage: self.logger.info("Login Test Passed") lst_status.append("Pass") self.loginPage.sign_out() else: lst_status.append("Fail") self.logger.info("Login Test Failed") allure.attach(self.driver.get_screenshot_as_png(), name=" Test DDT Login screen", attachment_type=AttachmentType.PNG) elif self.status == "False": if self.driver.title != self.homePage: lst_status.append("Pass") self.logger.info("Login Test Passed") allure.attach(self.driver.get_screenshot_as_png(), name=" Test DDT Login screen", attachment_type=AttachmentType.PNG) self.driver.save_screenshot(".\\Screenshots\\" + "test_Login_DDT.png") else: lst_status.append("Fail") self.logger.info("Login Test Failed") self.loginPage.sign_out() allure.attach(self.driver.get_screenshot_as_png(), name=" Test DDT Login screen", attachment_type=AttachmentType.PNG) if r == 6: self.logger.info("test_login_ddt", "Pass", "Login was successful") self.logger.info("******* Ending Login DDT Test **********") self.driver.close()
def test_login(self, setup): self.driver = setup self.logger.info("******** Test_001_Login --> test_login ********") self.driver.get(self.baseURL) self.login_page_obj = LoginPage(self.driver) self.login_page_obj.set_login_username(self.username) self.login_page_obj.set_login_password(self.password) self.login_page_obj.click_login_button() actual_loginpage_title = self.driver.title if actual_loginpage_title == "Dashboard / nopCommerce administration": assert True self.driver.close() self.logger.info( "******** Test_001_Login --> test_login --> PASSED ********") else: self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png") self.driver.close() self.logger.error( "******** Test_001_Login --> test_login --> FAILED ********") assert False
def test_inventory_menu_about(self, standard_user_cred): login_page = LoginPage(self.driver) if self.driver.current_url != "https://www.saucedemo.com/": login_page.goToLoginPage() login_page.setUsername(standard_user_cred[0]) login_page.setPassword((standard_user_cred[1])) login_page.clickLoginButton() inventory = Inventory(self.driver) inventory.clickBurgerButton() inventory.clickAbout() if self.driver.current_url == "https://saucelabs.com/": self.log.info( f":{self.__class__.test_inventory_menu_about.__name__}: {[*standard_user_cred]} :: TEST PASSED" ) self.driver.back() assert True else: self.log.info( f":{self.__class__.test_inventory_menu_about.__name__}: {[*standard_user_cred]} :: TEST FAILED" ) assert False
def test_Home_page_title(self): self.logger.info("*************Test Home page title ***************") self.logger.info( "*************Verifying Home Page Title ***************") self.loginPage = LoginPage(self.driver) self.loginPage.do_login(self.adminEmail, self.password) act_title = self.loginPage.get_home_page_title(self.title) if act_title == self.title: assert True self.driver.close() self.logger.info( "*************Home Page title test is pass***************") else: self.driver.save_screenshot(".\\Screenshots\\" + "test_Loginpage_title_is failed.png") self.driver.close() self.logger.error( "*************Home Page title test is failed***************") allure.attach(self.driver.get_screenshot_as_png(), name=" Home Page title test is failed ", attachment_type=AttachmentType.PNG) assert False
def test_login(driver): login_page = LoginPage(driver) driver.get("http://www.ukr.net") login_page.login(login, password) global checkin checkin = True assert login_page.login_username().is_displayed() is True #unittest.assertEqual(login_page.login_username().is_displayed(), True, "Login should be successfull") login_page.logout_button().click()
def login_as_a_user(): try: login_page = LoginPage(ShipRocket.driver) home_page_title = login_page.get_page_title() logging.info('Application is Launched in Browser') if home_page_title is 'eCommerce Logistics & Shipping Solutions: Multiple Courier Aggregator India': logging.info('Application Home Page Title is : ' + home_page_title) else: logging.info('Application Home Page Title is : ' + home_page_title) login_page.fill_email_address_field('*****@*****.**') logging.info('Enter email address in email field') login_page.fill_password_field('Sekhar@123') logging.info('Enter password in password field') login_page.click_login_button() logging.info('Click on login button') logging.info('User is Successfully Logged into Application') except Exception as e: raise AssertionError("Exception is ", e)
class Test_login(BaseTest): adminEmail = ReadConfig.getUserEmail() password = ReadConfig.getPassword() title = ReadConfig.getPageTitle() logger = LogGen.loggen() @allure.severity(allure.severity_level.MINOR) def test_click_here(self): self.logger = LogGen.loggen() self.logger.info("*************Test_Login***************") self.logger.info("*************verifying_click_here***************") self.loginPage = LoginPage(self.driver) flag = self.loginPage.is_forget_password_link_exist() assert flag self.driver.save_screenshot(".\\Screenshots\\" + "test_click_here.png") self.logger.info("*************Pass_click_here***************") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Click here screen", attachment_type=AttachmentType.PNG) @allure.severity(allure.severity_level.CRITICAL) def test_login_in(self): self.logger.info("*************Test_Login _in***************") self.logger.info("*************Verifying Login In***************") self.loginPage = LoginPage(self.driver) self.loginPage.do_login(self.adminEmail, self.password) self.driver.save_screenshot(".\\Screenshots\\" + "test_Login.png") self.logger.info("*************Pass Login in test***************") allure.attach(self.driver.get_screenshot_as_png(), name="Test login screen", attachment_type=AttachmentType.PNG) @allure.severity(allure.severity_level.CRITICAL) def test_Home_page_title(self): self.logger.info("*************Test Home page title ***************") self.logger.info( "*************Verifying Home Page Title ***************") self.loginPage = LoginPage(self.driver) self.loginPage.do_login(self.adminEmail, self.password) act_title = self.loginPage.get_home_page_title(self.title) if act_title == self.title: assert True self.driver.close() self.logger.info( "*************Home Page title test is pass***************") else: self.driver.save_screenshot(".\\Screenshots\\" + "test_Loginpage_title_is failed.png") self.driver.close() self.logger.error( "*************Home Page title test is failed***************") allure.attach(self.driver.get_screenshot_as_png(), name=" Home Page title test is failed ", attachment_type=AttachmentType.PNG) assert False
def test_invalid_login(self, invalid_login_data): login_page = LoginPage(self.driver) login_page.setUsername(invalid_login_data[0]) login_page.setPassword(invalid_login_data[1]) login_page.clickLoginButton() if self.driver.current_url != "https://www.saucedemo.com/inventory.html": self.log.info( f":{self.test_invalid_login.__name__}: {[*invalid_login_data]} :: TEST PASSED" ) assert True else: self.log.info( f":{self.test_invalid_login.__name__}: {[*invalid_login_data]} :: TEST FAILED" ) self.driver.back() assert False
class Test_001_Login: baseURL = ReadConfig.get_base_url() username = ReadConfig.get_username() password = ReadConfig.get_password() logger = LogGen.loggen() @pytest.mark.regression def test_homepage_title(self, setup): self.driver = setup self.logger.info( "******** Test_001_Login --> test_homepage_title ********") self.driver.get(self.baseURL) actual_homepage_title = self.driver.title if actual_homepage_title == "Your store. Login": assert True self.driver.close() self.logger.info( "******** Test_001_Login --> test_homepage_title --> PASSED ********" ) else: self.driver.save_screenshot(".\\Screenshots\\" + "test_homepage_title.png") self.driver.close() self.logger.error( "******** Test_001_Login --> test_homepage_title --> FAILED ********" ) assert False @pytest.mark.sanity @pytest.mark.regression def test_login(self, setup): self.driver = setup self.logger.info("******** Test_001_Login --> test_login ********") self.driver.get(self.baseURL) self.login_page_obj = LoginPage(self.driver) self.login_page_obj.set_login_username(self.username) self.login_page_obj.set_login_password(self.password) self.login_page_obj.click_login_button() actual_loginpage_title = self.driver.title if actual_loginpage_title == "Dashboard / nopCommerce administration": assert True self.driver.close() self.logger.info( "******** Test_001_Login --> test_login --> PASSED ********") else: self.driver.save_screenshot(".\\Screenshots\\" + "test_login.png") self.driver.close() self.logger.error( "******** Test_001_Login --> test_login --> FAILED ********") assert False
def test_customer_email_search(self, setup): self.driver = setup self.driver.get(self.baseURL) login_page_obj = LoginPage(self.driver) login_page_obj.set_login_username(self.username) login_page_obj.set_login_password(self.password) login_page_obj.click_login_button() self.customer_page_obj = AddCustomer(self.driver) self.customer_page_obj.click_menu_link_customers() self.customer_page_obj.click_menu_item_link_customers() self.customer_search_obj = CustomerSearch(self.driver) self.customer_search_obj.set_email("*****@*****.**") self.customer_search_obj.search_email( "*****@*****.**") self.customer_search_obj.set_first_name("Victoria") self.customer_search_obj.set_last_name("Terces") self.customer_search_obj.search_first_name("Victoria Terces")
def test_inventory_menu_x(self, standard_user_cred): login_page = LoginPage(self.driver) if self.driver.current_url == "https://www.saucedemo.com/": login_page.setUsername(standard_user_cred[0]) login_page.setPassword((standard_user_cred[1])) login_page.clickLoginButton() inventory = Inventory(self.driver) inventory.clickBurgerButton() inventory.clickCloseX() if self.driver.find_element( By.CSS_SELECTOR, "div.bm-menu-wrap").get_attribute("aria-hidden") == "true": self.log.info( f":{self.__class__.test_inventory_menu_x.__name__}: {[*standard_user_cred]} :: TEST PASSED" ) assert True else: self.log.info( f":{self.__class__.test_inventory_menu_x.__name__}: {[*standard_user_cred]} :: TEST FAILED" ) assert False
def test_login_with_wrong_credentials(driver): login_page = LoginPage(driver) driver.get("http://www.ukr.net") login_page.login("name", "pasword") assert login_page.error_message().is_displayed() is True
def test_A01_login_out(self): login = LoginPage(self.driver) login.sleep(3) login.click_logout() login.type_search_element(self.user_name, self.password) login.click_button_login()
def test_logout(driver): login_page = LoginPage(driver) driver.get("http://www.ukr.net") login_page.login(login, password) login_page.logout_button().click() assert login_page.login_button().is_displayed() is True
def test_login_with_credentials_in_all_uppercase(driver): login_page = LoginPage(driver) driver.get("http://www.ukr.net") login_page.login(login.upper(), password.upper()) assert login_page.error_message().is_displayed() is True