class Test_001_Login: baseurl=ReadConfig.getApplicationURL() username=ReadConfig.getuseremailL() password=ReadConfig.getuserpassword() logger=logGen.log_gen() @pytest.mark.regression def test_homepageTitle(self,setup): self.logger.info("*********Test_001_Login********") self.logger.info("*********Verifying Home page title**********") self.driver=setup self.driver.get(self.baseurl) act_title=self.driver.title if act_title=='Your store. Login': assert True self.driver.close() self.logger.info("******Home page title test is passed*******") else: self.driver.save_screenshot(".\\Screenshots\\"+"test_homepageTitle1.png") self.driver.close() self.logger.error("******Home page title test is failed*******") assert False @pytest.mark.sanity @pytest.mark.regression def test_Login(self,setup): self.logger.info("*********Verifying test_login**********") 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.clicklogin() act_title = self.driver.title if act_title == 'Dashboard / nopCommerce administration': assert True self.logger.info("******Login test is passed*******") self.driver.close() else: self.driver.save_screenshot(".\\Screenshots\\" + "test_Login1.png") self.driver.close() self.logger.error("******Login title test is failed*******") assert False self.driver.close()
class Test_searchcustomerbyEmail__004: baseurl = ReadConfig.getApplicationURL() username = ReadConfig.getuseremailL() password = ReadConfig.getuserpassword() logger = logGen.log_gen() @pytest.mark.regression def test_searchCustomerbyemail(self, setup): self.logger.info("****Test_004_SearchcustomerbyEmail****") self.driver = setup self.driver.get(self.baseurl) self.driver.maximize_window() self.driver.implicitly_wait(10) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clicklogin() self.logger.info("******Staring Search customer by Email") self.Add_cust = Add_customer(self.driver) self.Add_cust.clickcustomermenu() self.Add_cust.clickcustomermenuItem() self.logger.info("******Starting Search customer by Email") searchcust = Searchcustomer(self.driver) searchcust.setEmail("*****@*****.**") searchcust.clicksearch() time.sleep(5) status = searchcust.searchCustomerByEmail("*****@*****.**") assert True == status self.logger.info( "******Starting Search customer by Email Test case is finished") time.sleep(5) self.driver.close()
class Test_searchcustomerbyName__005: baseurl = ReadConfig.getApplicationURL() username = ReadConfig.getuseremailL() password = ReadConfig.getuserpassword() logger = logGen.log_gen() @pytest.mark.regression def test_searchCustomerbyName(self, setup): self.logger.info("****Test_005_SearchcustomerbyName****") self.driver = setup self.driver.get(self.baseurl) self.driver.maximize_window() self.driver.implicitly_wait(10) self.lp = LoginPage(self.driver) self.lp.setUsername(self.username) self.lp.setPassword(self.password) self.lp.clicklogin() self.logger.info("******Staring Search customer by Name") self.Add_cust = Add_customer(self.driver) self.Add_cust.clickcustomermenu() self.Add_cust.clickcustomermenuItem() self.logger.info("******Starting Search customer by Name") searchcust = Searchcustomer(self.driver) searchcust.setFirstname("Victoria") searchcust.setLastname("Terces") searchcust.clicksearch() time.sleep(5) status = searchcust.searchCustomerByName("Victoria Terces") assert True == status self.logger.info( "******Starting Search customer by Name Test case is finished") self.driver.close()
class Test_002_DDT_Login(): baseURL = ReadConfig.getApplicationURL() path = ".//TestData/signup.xlsx" logger = logGen.log_gen() # 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 = xlutills.getRowCount(self.path, 'login') print('Number of rows...', self.rows) lst_status = [] for r in range(2, self.rows + 1): self.user = xlutills.readData(self.path, 'login', r, 1) self.password = xlutills.readData(self.path, 'login', r, 2) self.exp = xlutills.readData(self.path, 'login', r, 3) self.lp.setUsername(self.user) 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.exp == 'Pass': self.logger.info("**** passed ****") self.lp.clicklogout() lst_status.append("Pass") elif self.exp == 'Fail': self.logger.info("**** failed ****") self.lp.clicklogout() 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 ************* ")
class Test_003_AddCustomer: baseurl = ReadConfig.getApplicationURL() usernamew = ReadConfig.getuseremailL() passord = ReadConfig.getuserpassword() logger = logGen.log_gen() @pytest.mark.sanity def test_addcustomer(self, setup): self.logger.info("****Test_003_Addcustomer****") self.driver = setup self.driver.get(self.baseurl) self.driver.maximize_window() self.driver.implicitly_wait(10) self.lp = LoginPage(self.driver) self.lp.setUsername(self.usernamew) self.lp.setPassword(self.passord) self.lp.clicklogin() self.addcust = Add_customer(self.driver) self.addcust.clickcustomermenu() self.addcust.clickcustomermenuItem() self.addcust.Add_new() self.email = random_generator( ) + "@gmail.com" ##creating a random data,the method has given below self.addcust.setEmail(self.email) self.addcust.setPassword('12345') self.firstname = random_generator() self.addcust.setFirstname(self.firstname) # self.addcust.setFirstname('rohit') self.addcust.setLastname('shelke') self.addcust.setDOB("2/05/1995") self.addcust.setGender("Male") self.addcust.setCompanyName("cattleya") self.addcust.setAdmincontent("gshvghs") #self.addcust.setDropdownVendor('Vendor 2') self.addcust.clickbtnsave() self.logger.info("******Add customer validaion started*****") ##below method it will capture everything on the page and it will convert it into text and will save it in variable self.msg self.msg = self.driver.find_element_by_tag_name("body").text print(self.msg) if "The new customer has been added successfully" in self.msg: ##checking "The new customer has been added successfully" this line is present in variable called self .msg assert True == True print("Add custmeter test is passed") self.logger.info("Add custmeter test is passed") else: self.driver.save_screenshot(".\\Screenshots\\" + "test_addcustomer_sc2.png") self.logger.info("Add custmeter test is failed") assert True == False self.driver.close() self.logger.info("****end of test_add_customer test case")