class Test_DDT_Login(BaseTest): baseURL = ReadConfig.getApplicationURL() path = ".//TestData/LoginData.xlsx" logger = LogGen.loggen() homePage = ReadConfig.getPageTitle() @pytest.mark.regression @allure.severity(allure.severity_level.CRITICAL) 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()
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_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)
class Test_new_orders(BaseTest): logger = LogGen.loggen() adminEmail = ReadConfig.getUserEmail() password = ReadConfig.getPassword() def test_neworder_confirm(self): self.logger.info("********** test new order starting *******") self.newOrders = New_orders(self.driver) self.logger.info("******** test new order verifiing *********") self.logger.info("******** login on admin page *********") self.newOrders.do_login(self.adminEmail, self.password) self.newOrders.click_order_menu() try: self.newOrders.new_order_info() self.newOrders.table_order_data() self.logger.info("******** Test new order is passed *******") self.driver.save_screenshot(".//Screenshots//" + "test_new_order_confirm.png") except NoSuchElementException: self.logger.error( "********** Test new order is failed ***********")
class Test_shop_asGuest(BaseTest): logger = LogGen.loggen() path = "TestData/LoginData (version 1).xlsx" @allure.severity(allure.severity_level.NORMAL) def test_guest_shopping(self): self.pro_rows = XLUtils.getRowCount(self.path, 'Products') for i in range(2, self.pro_rows + 1): self.menu = XLUtils.readData(self.path, 'Products', i, 1) self.submenu = XLUtils.readData(self.path, 'Products', i, 2) self.item = XLUtils.readData(self.path, 'Products', i, 3) self.shop = Shopping(self.driver) self.shop.Titlebar(self.menu) if self.submenu != "x": self.shop.Submenu(self.submenu) self.shop.Item(self.item) self.logger.info("******* item added to cart **********") self.driver.save_screenshot(".\\Screenshots\\" + " .png") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Shopping item", attachment_type=AttachmentType.PNG)
class Test_customer_signIn(BaseTest): logger = LogGen.loggen() path = ".//TestData/LoginData (version 1).xlsx" @pytest.mark.sanity @pytest.mark.regression @allure.severity(allure.severity_level.CRITICAL) def test_customer_signIn(self): self.c_sign = RegisterCustomer(self.driver) self.c_sign.c_sign_in() self.logger.info("********* Test customer sign in started *************") self.logger.info("********* Test customer sign in verifying *************") self.rows = XLUtils.getRowCount(self.path, 'Customer') self.c_email = XLUtils.readData(self.path, 'Customer', 2, 1) self.c_passwd = XLUtils.readData(self.path, 'Customer', 2, 2) sign_in = self.c_sign.registerCustomer(self.c_email, self.c_passwd) if sign_in == self.c_sign.welcome_header: self.logger.info("******** Customer Sign in Account ********") self.driver.save_screenshot(".\\Screenshots\\" + "customer_sign_in .png") allure.attach(self.driver.get_screenshot_as_png(), name=" Test customer sign in", attachment_type=AttachmentType.PNG) self.c_sign.signOut() else: self.driver.save_screenshot(".\\Screenshots\\" + "customer_sign_in_Fail.png") self.c_sign.checkSignin() self.logger.error("******** customer sign in failed ********** ") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Customer sign in is failed ", attachment_type=AttachmentType.PNG) self.logger.info("********* Test customer sign in passed *************") self.logger.info("********* Test customer sign in finished *************") self.driver.close()
class Test_Shopping_Cart(BaseTest): logger = LogGen.loggen() path = "TestData/LoginData (version 1).xlsx" @pytest.mark.sanity @allure.severity(allure.severity_level.NORMAL) def test_Store_homePagetitle(self): self.shop = Shopping(self.driver) self.logger.info( "************* test store Home Page title test is started ***************" ) self.logger.info( "************* Verifying store Home Page title test **************" ) act_title = self.shop.shop_title() if act_title == self.driver.title: self.logger.info( "************* test store Home Page title test is pass***************" ) print(act_title) assert True else: self.driver.save_screenshot(".\\Screenshots\\" + "test_store_homepage_title.png") self.logger.info( "*************Home Page title test is fail ***************") @pytest.mark.regression @allure.severity(allure.severity_level.NORMAL) def test_shop_rcustomer(self): self.logger.info("******** Sign in as Register customer ******** ") self.sigin = RegisterCustomer(self.driver) self.rows = XLUtils.getRowCount(self.path, 'Customer') self.email = XLUtils.readData(self.path, 'Customer', 2, 1) self.passwd = XLUtils.readData(self.path, 'Customer', 2, 2) self.sigin.registerCustomer(self.email, self.passwd) self.pro_rows = XLUtils.getRowCount(self.path, 'Products') for i in range(2, self.pro_rows + 1): self.menu = XLUtils.readData(self.path, 'Products', i, 1) self.submenu = XLUtils.readData(self.path, 'Products', i, 2) self.item = XLUtils.readData(self.path, 'Products', i, 3) self.shop = Shopping(self.driver) self.shop.Titlebar(self.menu) if self.submenu != "x": self.shop.Submenu(self.submenu) self.shop.Item(self.item) self.logger.info("******* item added to cart **********") print("item added to cart") self.billing = Billing(self.driver) self.billing.cart_btn_click() self.billing.checkout_btn_click() self.billing.checkbox_click() self.billing.c_checkout() self.billing.shipping_op_radio() self.billing.checkout_button_click() self.billing.place_order_click() try: self.billing.order_msg_no() self.logger.info("***** Order placed successfully *******") self.driver.save_screenshot( ".\\Screenshots\\" + " test_shopping_cart order placed successfully .png") except NoSuchElementException: self.logger.info("***** order havn't placed *******") self.logger.error("***** error occur to place the order *******") self.driver.save_screenshot( ".\\Screenshots\\" + " test _shopping_cart error occur to place the order .png") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Shopping Cart error occur", attachment_type=AttachmentType.PNG) self.sigin.signOut()
class Test_billing_shipping(BaseTest): logger = LogGen.loggen() path = "TestData/guest.xlsx" @pytest.mark.sanity @allure.severity(allure.severity_level.NORMAL) def test_addtocart(self): self.logger.info("******* veriying billing form **********") self.billing = Billing(self.driver) self.billing.shop_product() self.driver.save_screenshot(".\\Screenshots\\" + " test form .png") @pytest.mark.sanity @pytest.mark.regression @allure.severity(allure.severity_level.NORMAL) def test_billing_from(self): self.billing = Billing(self.driver) self.logger.info("********* Test Billing form *********") self.billing.cart_btn_click() self.billing.checkout_btn_click() self.logger.info("********* Reading Data from Excel *********") self.guest = XLUtils.getRowCount(self.path, 'Sheet1') print("number of rows g excel : ", self.guest) try: self.billing.check_billing_form() for g in range(2, self.guest + 1): self.name = XLUtils.readData(self.path, 'Sheet1', g, 1) self.lname = XLUtils.readData(self.path, 'Sheet1', g, 2) self.email = XLUtils.readData(self.path, 'Sheet1', g, 3) self.zcode = XLUtils.readData(self.path, 'Sheet1', g, 4) self.city = XLUtils.readData(self.path, 'Sheet1', g, 5) self.address = XLUtils.readData(self.path, 'Sheet1', g, 6) self.Phone = XLUtils.readData(self.path, 'Sheet1', g, 7) self.billing.fill_billing_form1(self.name, self.lname, self.email) self.billing.fill_billing_form2(self.zcode, self.city, self.address, self.Phone) self.logger.info( "************* DDT form data entered ************") except NoSuchElementException: self.driver.save_screenshot(".\\Screenshots\\" + " test Billing form .png") self.logger.info( "******* Test Billing form coudn't find **********") self.logger.error("***** error occur *******") self.billing.checkbox_click() self.billing.c_checkout() self.logger.info("********* checkout continue *********") self.billing.shipping_op_radio() self.billing.checkout_button_click() self.billing.place_order_click() try: self.billing.order_msg_no() self.driver.save_screenshot(".\\Screenshots\\" + " test Billing order placed .png") self.logger.info("***** Order placed successfully *******") except NoSuchElementException: self.logger.error("***** order havn't placed *******") self.logger.error("***** error occur *******") self.driver.save_screenshot(".\\Screenshots\\" + " test Billing_form order error .png") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Billing form order error", attachment_type=AttachmentType.PNG) self.driver.close()
class Test_register_customer(BaseTest): logger = LogGen.loggen() path = ".//TestData/LoginData (version 1).xlsx" @pytest.mark.sanity @pytest.mark.regression @allure.severity(allure.severity_level.CRITICAL) def test_sign_in(self): self.logger.info("*************Test Sign in ***************") self.logger.info("*************Verifying Sign in ***************") self.signin = RegisterCustomer(self.driver) self.signin.sign_in_link() self.driver.save_screenshot(".\\Screenshots\\" + "test_Sign in.png") self.logger.info("************* test sign in passed ************") @pytest.mark.sanity @pytest.mark.regression @allure.severity(allure.severity_level.CRITICAL) def test_register_Customer(self): self.reg = RegisterCustomer(self.driver) self.reg.Register_button() self.logger.info( "**************test_register_customer_ddt*************************" ) self.logger.info( "******* started Register Customer DDT Test **********") self.rows = XLUtils.getRowCount(self.path, 'Customer') print("count excel file rows : ", self.rows) self.logger.info("******* Reading data from excel **********") self.email = self.reg.random_generator() + '@gmail.com' self.logger.info("******* New customer email entered **********") for r in range(2, self.rows): self.password = XLUtils.readData(self.path, 'Customer', r, 2) self.repasswd = XLUtils.readData(self.path, 'Customer', r, 3) self.fname = XLUtils.readData(self.path, 'Customer', r, 4) self.lname = XLUtils.readData(self.path, 'Customer', r, 5) self.zipcode = XLUtils.readData(self.path, 'Customer', r, 6) self.address = XLUtils.readData(self.path, 'Customer', r, 7) self.phone = XLUtils.readData(self.path, 'Customer', r, 8) reg = self.reg.registerForm(self.email, self.password, self.repasswd, self.fname, self.lname, self.zipcode, self.address, self.phone) self.driver.save_screenshot(".\\Screenshots\\" + "registration.png") self.logger.info( "******* test_register_customer_ddt , Data added to form **********" ) if reg == self.reg.checkRegister(): assert True else: self.driver.save_screenshot(".\\Screenshots\\" + "registration.png") self.logger.info("test_register_customer_ddt", "Pass", "Registration was successful") self.logger.info( "******* Ending Register Customer DDT Test **********") allure.attach(self.driver.get_screenshot_as_png(), name=" Test Register Customer Sucessful", attachment_type=AttachmentType.PNG) self.reg.signOut() self.driver.close()