def test_checkOutPage(self): checkoutobj = CheckOutPage(self.driver) self.driver.refresh() time.sleep(3) checkoutRadio = checkoutobj.getcheckoutRadio() for radiobutton in checkoutRadio: if radiobutton.text == "Delivery": radiobutton.click()
def test_paymentMethods(self): checkoutobj = CheckOutPage(self.driver) checkoutRadio = checkoutobj.getcheckoutRadio() for radiobutton in checkoutRadio: if radiobutton.text == "Cash on Delivery": radiobutton.click() time.sleep(2)
def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) homePage.shopItems().click() #self.driver.get_screenshot_as_file("rahul.png") checkOutPage = CheckOutPage(self.driver) products = checkOutPage.getProducts() # //*[@class='card h-100']/div/h4/a for product in products: productName = product.find_element_by_xpath("//*[@class='card h-100']/div/h4/a").text log.info("Product name ==> "+productName) if productName == "Blackberry": product.find_element_by_xpath("//*[@class='card h-100']/div[2]/button").click() self.driver.find_element_by_xpath("//a[@class='nav-link btn btn-primary']").click() self.driver.find_element_by_xpath("//*[contains(text(),'Checkout')]").click() log.info("Typing a country name") self.driver.find_element_by_id("country").send_keys("Turkey") #wait = WebDriverWait(self.driver, 10) #wait.until(expected_conditions.element_to_be_clickable((By.XPATH, "//*[@class='suggestions']//li/a"))) self.webDriverWait(10,(By.XPATH, "//*[@class='suggestions']//li/a")) # time.sleep(10) self.driver.find_element_by_xpath("//*[@class='suggestions']//li/a").click() self.driver.find_element_by_xpath("//*[contains(text(),'agree with')]").click() self.driver.find_element_by_xpath("//*[@type='submit']").click() message = self.driver.find_element_by_xpath("//*[contains(@class,'alert-dismissible')]").text log.info("The alert message ==> "+message) assert "Thank dfghgjyou!" in message
def shopItems(self): # self.driver.find_element_by_link_text("Shop").click() self.driver.find_element(*HomePage.shopLink).click() # Instead of creating checkout object in the teste2e(test case), we are creating it in the method that # clicks the shoplink, calls and returns the checkoutpage object checkoutpage = CheckOutPage(self.driver) return checkoutpage
def test_e2e(self): # self points to request.cls.driver homepage = HomePage( self.driver ) # driver created in conftest file.So to access this here self.driver # homepage.shopItems().click() checkOutPage = CheckOutPage(self.driver) no need to create objects in test # case file.....bcoz if 10 pages in T.C(means 10 classes),we need to create 10 objects.... to avoid that, # first figure out what is the integration point between page create object for next page and return that # object checkoutpage = homepage.shopItems( ) # shopitems returns objects of next page,so skipped creating object in T.C cards = checkoutpage.getCardTitles() i = -1 for card in cards: i = i + 1 print(card.text) if card.text == "Blackberry": checkoutpage.getCardFooter()[i].click() self.driver.find_element_by.css_selector( "//a[@class*='btn-primary']").click() confirmPage = CheckOutPage.checkOutItems() self.driver.find_element_by(By.ID, "country").send_leys("ind") # its better to write explicit wait mech. in Baseclass(bcoz every T.C we are using it).. # called custom utilities.... T.C inherits Baseclass. self.verifyLinkPresence( "india" ) # as baseclass is inherited so baseclass object points to self... # using self we call baseclass properties assert ("abed" in cards)
def shopItems(self): self.driver.find_element(*HomePage.shop).click() checkOutPage = CheckOutPage(self.driver) return checkOutPage
def test_timeSlot(self): checkoutobj = CheckOutPage(self.driver) checkoutobj.clickDatePicker().click() csslocatorDate = checkoutobj.csspickdate self.verifyCssPresence(csslocatorDate) checkoutobj.clickPickDateCssButton().click() checkoutobj.clickSelectDate().click() scrollPath = checkoutobj.scrollPageXpath self.verifyXpathPresence(scrollPath) checkoutobj.clickScrollXpathButton().click() self.scrollDown(scrollPath) time.sleep(2) checkoutobj.selectTimeSlot().click()
def test_checkOutAddAddress(self): checkoutobj = CheckOutPage(self.driver) time.sleep(2) checkoutobj.enterAddressName().send_keys("Test") checkoutobj.clickPincodeDropdown().click() time.sleep(2) xpathlocatorPincode = checkoutobj.pincodeXpath self.verifyXpathPresence(xpathlocatorPincode) checkoutobj.clickOnPincode().click() time.sleep(2) checkoutobj.clickAreaDropdown().click() xpathlocatorArea = checkoutobj.areaXpath self.verifyXpathPresence(xpathlocatorArea) checkoutobj.clickOnArea().click() time.sleep(2) checkoutobj.enterAddress().send_keys("9th Main Rd, HBR Layout 4th Block") checkoutobj.enterLandMark().send_keys("FAITH AG PRAYER FELLOWSHIP") checkoutobj.enterMobileNumber().send_keys("8971393466") checkoutobj.clickSubmitAddress().click() TestOne.test_popupmsg(self)
def getCheckOutButton(self): """This returns the checkout button in Shop Page""" self.driver.find_element(*ShopPage.checkOutButton).click() objCheckOutPage = CheckOutPage(self.driver) return objCheckOutPage
def shopItems(self): # driver.findelement(by.css_selector,"a[href='/angularpractice/shop']") # return self.driver.find_element(*HomePage.shop) self.driver.find_element(*HomePage.shop).click() checkOutPage = CheckOutPage(self.driver) return checkOutPage