def test_tc1login(self): driver = self.driver driver.get(utils.url) lp = loginPage(driver) lp.entersername(utils.username) lp.enterusersassword(utils.password) lp.clickonloginbtn()
def test_login(self, setUp): self.logger.info("************ Test_Login **************") self.logger.info( "************ Verifying login to the application **************") self.driver = setUp self.driver.maximize_window() self.driver.get(self.baseUrl) self.lp = loginPage(self.driver) self.lp.enterUsername(self.uname) self.lp.enterPassword(self.pwd) self.lp.clickOnLoginButton() home_title = self.driver.title if home_title == "Dashboard / nopCommerce administration": self.driver.quit() self.logger.info("************ Login test passed **************") assert True else: self.driver.save_screenshot("../screenshots/" + "test_login" + ".png") self.driver.quit() self.logger.error("************ Login test failed **************") assert False
def test_add_customer(self, setUp): self.logger.info("************ Test_Add_Customer **************") self.driver = setUp self.driver.maximize_window() self.driver.get(self.baseUrl) self.lp = loginPage(self.driver) self.lp.enterUsername(self.uname) self.lp.enterPassword(self.pwd) self.lp.clickOnLoginButton() self.logger.info("************ Starting Add Customer Test **************") self.hp = homePage(self.driver) self.hp.clickOnCustMainMenu() self.hp.clickOnCustSubMenu() self.custsearch = custSearchPage(self.driver) self.custsearch.clickOnAddNewBtn() self.addcust = addCustPage(self.driver) self.email = cu.random_generator(self) + "@gmail.com" self.addcust.enterCustEmail(self.email) self.addcust.enterCustPassword("test123") self.addcust.enterFirstName("Bobby") self.addcust.enterLastName("Fischer") self.addcust.selectGender("Male") self.addcust.enterDOB("09/03/1943") self.addcust.enterCompany("Chess Base") self.addcust.checkTaxExempt() self.addcust.selectNewsletter("Test store 2") self.addcust.selectCustRoles("Guests") self.addcust.selectManagerOfVendors("Vendor 1") self.addcust.checkActive() self.addcust.enterAdminComment("Customer details entered") sleep(2) self.addcust.clickOnSaveBtn() self.logger.info("************ Saving Customer Info **************") self.logger.info("************ Starting Add Customer Validation **************") self.msg = self.driver.find_element_by_xpath("//div[@class='alert alert-success alert-dismissable']").text if "The new customer has been added successfully" in self.msg: self.logger.info("************ Add Customer Test Passed **************") assert True else: self.driver.save_screenshot("../screenshots/"+"test_add_cust"+".png") self.logger.info("************ Add Customer Test Failed **************") assert False self.driver.quit() self.logger.info("************ Add Customer Test Completed **************")
def test_orangeHrm_Login(self): lp = loginPage(self.driver) lp.enterUsername(self.username) lp.enterPassword(self.password) lp.clickOnLoginBtn() self.assertEqual("OrangeHRM", self.driver.title, "Page title are not same")
def test_search_customer_by_email(self, setUp): self.logger.info( "************ Test_Search_Customer_By_Email **************") self.driver = setUp self.driver.maximize_window() self.driver.get(self.baseUrl) self.lp = loginPage(self.driver) self.lp.enterUsername(self.uname) self.lp.enterPassword(self.pwd) self.lp.clickOnLoginButton() self.logger.info( "************ Starting Search Customer Test **************") self.hp = homePage(self.driver) self.hp.clickOnCustMainMenu() self.hp.clickOnCustSubMenu() self.custsearch = custSearchPage(self.driver) self.custsearch.enterEmail("*****@*****.**") self.custsearch.clickOnSearchBtn() self.logger.info("************ Searching Customer **************") sleep(5) search_status = self.custsearch.searchCustByEmail( "*****@*****.**") if search_status == True: self.logger.info( "************ Search Customer Test Passed **************") assert True else: self.driver.save_screenshot("../screenshots/" + "test_search_cust_by_email" + ".png") self.logger.info( "************ Search Customer Test Failed **************") assert False self.driver.quit() self.logger.info( "************ Search Customer Test Completed **************")
def test_login(self): driver = self.driver driver.get(utils.URL) login = loginPage(driver) login.enter_username(utils.USERNAME) login.click_username_button() time.sleep(2) login.enter_password(utils.PASSWORD) login.click_password_button() time.sleep(4) home = HomePage(driver) home.click_menu_icon() home.click_Gmail_icon() time.sleep(2) try: titlePage = driver.title assert titlePage == "Googl Account" print("User logged into", titlePage, "Successfully!") time.sleep(2) except AssertionError as error: print("Assertion error occurred") print(error) currtime = moment.now().strftime("%d-%m-%Y_%H-%M-%S") testname = utils.whoami() screenshotname = testname + "_" + currtime allure.attach(self.driver.get_screenshot_as_png(), name=screenshotname, attachment_type=allure.attachment_type.PNG) driver.get_screenshot_as_file( "C:/Users/Sadhana/PycharmProjects/AutomationFramework1/screenshots/" + screenshotname + ".png") raise else: print("No exceptions occurred") finally: print("We are inside finally block")
def test_login_ddt(self, setUp): self.logger.info("************ Test_Login_DDT Started**************") self.logger.info( "************ Verifying login to the application using DDT **************" ) self.driver = setUp self.driver.maximize_window() self.driver.get(self.baseUrl) self.lp = loginPage(self.driver) self.hp = homePage(self.driver) test_status = [] self.rows = xl.getRowCount(Config.dataFile, Config.dataSheet) print("No. of rows : " + str(int(self.rows) - 1)) for row in range(2, self.rows + 1): self.uname = xl.readData(Config.dataFile, Config.dataSheet, row, 1) self.pwd = xl.readData(Config.dataFile, Config.dataSheet, row, 2) self.exp = xl.readData(Config.dataFile, Config.dataSheet, row, 3) self.lp.enterUsername(self.uname) self.lp.enterPassword(self.pwd) self.lp.clickOnLoginButton() sleep(5) exp_title = "Dashboard / nopCommerce administration" act_title = self.driver.title if act_title == exp_title: if self.exp == "Pass": self.logger.info("*** Passed ***") self.hp.clickOnLogoutLink() test_status.append("Pass") elif self.exp == "Fail": self.driver.save_screenshot("../screenshots/" + "test_login_ddt" + self.uname + "_" + self.pwd + ".png") self.logger.info("*** Failed ***") self.hp.clickOnLogoutLink() test_status.append("Fail") elif act_title != exp_title: if self.exp == "Pass": self.driver.save_screenshot("../screenshots/" + "test_login_ddt" + self.uname + "_" + self.pwd + ".png") self.logger.info("*** Failed ***") test_status.append("Fail") elif self.exp == "Fail": self.logger.info("*** Passed ***") test_status.append("Pass") if "Fail" not in test_status: self.logger.info( "************ Login Test DDT Passed **************") self.driver.quit() assert True else: self.driver.quit() self.logger.error( "************ Login Test DDT Failed **************") assert False self.logger.info( "************ Test_Login_DDT Completed **************")