class Test_searchCustBY_Fname: baseURL = Readconfig.getAppURL() username = Readconfig.getUseName() password = Readconfig.getPassWord() logger_object = LoG.log_gen() def test_searchCustby_Fname(self,setup): self.logger_object.info("***search customer by_first Name") self.driver =setup self.driver.get(self.baseURL) self.logger_object.info("******Login the application****") self.LP =Loginpage(self.driver) self.LP.setUserName(self.username) self.LP.setPassword(self.password) self.LP.clickLogin() time.sleep(3) self.addCust =addCustomer(self.driver) self.addCust.clickOnCustomerMenu() self.addCust.clickOnCustomerSubMenu() self.SFN=search_customer(self.driver) self.SFN.setFname("James") self.SFN.setLName("Pan") self.SFN.clickSearch() time.sleep(10) status = self.SFN.searchCustbyname("James Pan") time.sleep(5) assert True ==status self.logger_object.info("****search customer by fname test caseis passed***")
class Test_searchCustBY_email: baseURL = Readconfig.getAppURL() username = Readconfig.getUseName() password = Readconfig.getPassWord() logger_object = LoG.log_gen() @pytest.mark.Regression def test_searchCustby_Email(self, setup): self.logger_object.info("***search customer by_email") self.driver = setup self.driver.get(self.baseURL) self.logger_object.info("******Login the application****") self.LP = Loginpage(self.driver) self.LP.setUserName(self.username) self.LP.setPassword(self.password) self.LP.clickLogin() time.sleep(3) self.addCust = addCustomer(self.driver) self.addCust.clickOnCustomerMenu() self.addCust.clickOnCustomerSubMenu() self.SEmail = search_customer(self.driver) self.SEmail.setEmail("*****@*****.**") self.SEmail.clickSearch() time.sleep(10) status = self.SEmail.searchCustbyEmail( "*****@*****.**") time.sleep(5) self.driver.implicitly_wait(5) assert True == status self.logger_object.info("****search customer test caseis passed***") self.driver.close()
class Test_003_addCustomer: baseURL = Readconfig.getAppURL() username = Readconfig.getUseName() password = Readconfig.getPassWord() logger_object = LoG.log_gen() @pytest.mark.sanity @pytest.mark.Regression def test_addCustomer(self, setup): 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() actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: assert True self.logger_object.info("****Loggin test is passed*****") else: self.driver.get_screenshot_as_file( filename="/Screenshots\\test_003_addCustomer.png") self.driver.close() self.logger_object.info("****Loggin test is failed*****") assert False self.logger_object.info("****start AddCustomer Test*****") self.addCust = addCustomer(self.driver) self.addCust.clickOnCustomerMenu() self.addCust.clickOnCustomerSubMenu() self.addCust.clickOnAddNew() self.logger_object.info("***Provide Customer information****") self.email = random_generator() + "@gmail.com" self.addCust.setEmail(self.email) self.addCust.setpassword("test123") self.addCust.setFirstName("sairam") self.addCust.setLastName("Hari") time.sleep(6) self.addCust.setGender("Male") time.sleep(6) self.addCust.setDOB("01/01/1870") self.addCust.setCompanyName("shiridiIndia") time.sleep(15) # self.addCust.setNewsletter("HELLO") #self.addCust.setCustomerroles("") self.addCust.setCustomerroles("Guests") self.addCust.setCustomerroles("Forum Moderators") time.sleep(15) self.addCust.setManagerOfVendor("Vendor 1") time.sleep(10) self.addCust.setAdminComment("This is for Testing purpose1") self.addCust.click_save() self.logger_object.info("****saving customer informatiion****") self.logger_object.info("***starting add customer validation***") self.msg = self.driver.find_element_by_tag_name("body").text print(self.msg)
class Test_001_login: baseURL= Readconfig.getAppURL() username = Readconfig.getUseName() password =Readconfig.getPassWord() logger_object =LoG.log_gen() def test_homepageTitle(self, setup): self.logger_object.info("****Test_001_Login*****") self.logger_object.info("****verify_homePage*****") self.driver = setup self.driver.get(self.baseURL) actual_title = self.driver.title expected_title = "Your store. Login" if actual_title == expected_title: assert True self.driver.close() self.logger_object.info("****Home Page title test is passed*****") else: self.driver.close() self.logger_object.info("****Home Page title test is failed*****") assert False @pytest.mark.sanity def test_login(self, setup): self.logger_object.info("****Verify Login Page *****") 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() actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: assert True self.logger_object.info("****Loggin test is passed*****") else: self.driver.get_screenshot_as_file(filename ="/Screenshots\\test_login_001.png") self.driver.close() self.logger_object.info("****Loggin test is failed*****") assert False self.logger_object.info("****Test complete*****") self.logger_object.info("****Thanks*****") self.LP.clicklogout()
class Test_ddt_002: baseURL = Readconfig.getAppURL() path = "C:\\Users\\rohit\\PycharmProjects\\NOPCOM\\TestData\\Book2.xlsx" LO = LoG.log_gen() @pytest.mark.Regression def test_login_DDT(self, setup): self.LO.info("*****Test_ddt_002****") self.LO.info("****Verify Login page****") self.driver = setup self.driver.get(self.baseURL) self.LP = Loginpage(self.driver) self.rows = XLUtils.getRowCount(self.path, sheetName="Sheet1") self.columns = XLUtils.getColumnCount(self.path, sheetName="Sheet1") print(" No of rows in excel:", self.rows) print("No of columns in excel", self.columns) Lis_status = [] #print(Lis_status) for r in range(2, self.rows + 1): self.username = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=1) self.password = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=2) self.expected = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=3) self.output = XLUtils.readData(self.path, sheetName="Sheet1", rownum=r, columnno=4) self.LP.setUserName(self.username) self.LP.setPassword(self.password) self.LP.clickLogin() time.sleep(10) actual_title = self.driver.title expected_title = "Dashboard / nopCommerce administration" if actual_title == expected_title: if self.expected == "pass": self.LO.info("***Passed") self.LP.clicklogout() time.sleep(3) Lis_status.append("Pass") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Pass") elif self.expected == "fail": self.LO.info("***Failed") self.LP.clicklogout() time.sleep(10) Lis_status.append("Fail") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Fail") elif actual_title != expected_title: if self.expected == "pass": self.LO.info("****Failed") Lis_status.append("Fail") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Fail") time.sleep(10) elif self.expected == "fail": self.LO.info("****Passed") Lis_status.append("Pass") self.output = XLUtils.writeData(self.path, sheetName="Sheet1", rownum=r, columnno=4, data="Pass") time.sleep(5) if "Fail" not in Lis_status: self.LO.info("The DDT test is passed") self.driver.close() assert True else: self.LO.info("the DDT test is failed") self.driver.close() assert False self.LO.info("End of Login_DDT test") self.LO.info("complete the test case for data driven")