def test_e2e(self): log = self.getlogger() homepage = Homepage(self.driver) checkoutpage = homepage.shopItems() log.info("getting all the cart titles") product = checkoutpage.productFromList() for item in product: producttext = item.text if producttext == "Blackberry": checkoutpage.getNameFooter().click() checkoutpage.checkoutItems().click() checkoutpage.checkoutConfirmSuccess().click() log.info("Entering country name as Ind") checkoutpage.countrySelectFromList().send_keys("ind") self.verifyLinkPresence("India") checkoutpage.CountrySelectIndia().click() checkoutpage.checkBox().click() checkoutpage.purchase().click() confirmpage = ConfirmPage(self.driver) successmessage = confirmpage.successMessage().text log.info("Text received from application is " + successmessage) assert "Success! Thank you!" in successmessage
def test_EndtoEnd(self): log = self.getLogger() homePage = HomePage(self.driver) homePage.shopItems().click() checkOutPage = CheckoutPage(self.driver) products = checkOutPage.checkoutItems() for product in products: productName = product.find_element_by_xpath("div/h4/a").text log.info(productName) if productName == "Blackberry": product.find_element_by_xpath("div[2]/button").click() checkOutPage.checkoutButton().click() # checkout proceed checkOutPage.checkoutFinalButton().click() # Checkout Final confirmPage_Obj = ConfirmPage(self.driver) confirmPage_Obj.addressDropdown().send_keys("ind") # wait = WebDriverWait(self.driver, 8) # wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India"))) log.info("Country Selection") self.VerifyLinkPresence("India") # Optimized in BaseClass confirmPage_Obj.addressSelection().click() confirmPage_Obj.purchaseButton().click() successText = confirmPage_Obj.successText().text log.info("Success Text : " + successText) assert "Success" in successText self.driver.get_screenshot_as_file("screenshot1.png") # method to get screenshot
def test_checkGooglePage(self): log = self.getLogger() log.info("1. get the search field on google home page.") # step 01 : homePage = HomePage(self.driver) homePage.getSearchField().send_keys("cheerios") homePage.getButtonGoogleSearch().click() time.sleep(3) log.info("2. confirm the results page. Find 'www.cheerios.com'. ") confirmPage = ConfirmPage(self.driver) confirmPage.getSearchResult()
def test_e2e(self): log = self.test_getLogger() homePage = HomePage(self.driver) homePage.shopItems().click() self.driver.implicitly_wait(5) ##Choose All Products and Parent-Child Tag Movement Concept Application checkoutPage = CheckoutPage(self.driver) log.info("Getting all the Cart Titles") Products = checkoutPage.getproductItems() ProductName = checkoutPage.getProductName() ProductButton = checkoutPage.getProductButton() i = -1 for product in ProductName: i = i+1 ProdName = product.text log.info(ProdName) if ProdName == "Blackberry": ProductButton[i].click() break # Proceed to Checkout firstCheckOut = checkoutPage.getCheckoutPageConfirm() firstCheckOut.click() finalCheckOut = checkoutPage.getFinalCheckoutConfirm() finalCheckOut.click() ##Confirm Page - Auto Suggestive Dropdown List confirmPage = ConfirmPage(self.driver) log.info("Entering Country Name as Ind") sendCountry = confirmPage.getCountry() sendCountry.send_keys("Ind") #Explicit wait - Common in Base Class self.verifyLinkPresenceWait("India") confirmPage.getSelectedCountry().click() confirmPage.getClickCheckBox().click() confirmPage.getPurchaseButton().click() assert self.driver.find_element_by_xpath("//input[@id='checkbox2']").is_selected() ##Validate Text print(self.driver.find_element_by_xpath("//div[@class='alert alert-success alert-dismissible']").text) Sucess_Text = "Success! Thank you! Your order will be delivered in next few weeks :-)." log.info("Test received from Apllication is: "+Sucess_Text) log.info("Succesfull Shopping -- Happy to Serve you") assert "Success! Thank you" in Sucess_Text
def test_e2e(self): log = self.getLogger() homePage = HomePage(self.driver) checkoutpage = homePage.shopItem() log.info("getting all the card titles") cards = checkoutpage.getCardTitles() i = -1 for card in cards: i = i + 1 cardText = card.text log.info(cardText) if cardText == "Blackberry": checkoutpage.getCardFooter()[i].click() #1 checkIns = CheckOutPage.getcheckIn(self) checkIns.click() #2 confirmPage = CheckOutPage.checkOutItems(self) log.info("Entering country name as ind") locationin = ConfirmPage.getlocation(self) locationin.send_keys("ind") self.driver.find_element_by_id("country") time.sleep(7) self.verifyLinkPresence("India") self.driver.find_element_by_link_text("India").click() self.driver.find_element_by_xpath("//div[@class='checkbox checkbox-primary']").click() self.driver.find_element_by_css_selector("[type='submit']").click() textMatch = self.driver.find_element_by_css_selector("[class*='alert-success']").text log.info("Text received from application is "+textMatch) assert ("Success! Thank you!" in textMatch)
def test_e2e(self): log = self.GetLogger() self.driver.implicitly_wait(5) homePage = HomePage(self.driver) # calling page objects # driver.find_element_by_css_selector("a[href*='shop']").click() # homePage.ClickShopLink().click() checkoutpage = homePage.ClickShopLink() # checkoutpage = CheckoutPage(self.driver) log.info("Getting all the cart titles") products = checkoutpage.GetCardTitles() # products = driver.find_elements_byC:\Python\PythonSelfFramework_xpath("//div[@class='card h-100']") # //div[@class='card h-100']/div/h4/a for product in products: productname = product.find_element_by_xpath("div/h4/a").text log.info("product name:" + productname) if productname == "Blackberry": # checkoutpage.ClickAddButton().click() product.find_element_by_xpath("div/button").click() # self.driver.find_element_by_css_selector("a[class*='btn-primary']").click() checkoutpage.ClickCheckOutButton().click() # the elements correct values for check out checkoutitems = self.driver.find_elements_by_xpath( "//*[contains(@class,'table-hover')]/tbody/tr/td/div/div/h4/a") for item in checkoutitems: if item.text == "Blackberry": # print(" correct value checkout:" + item.text) log.info(" correct value checkout:" + item.text) confirmpage = checkoutpage.ClickSucessButton() # self.driver.find_element_by_css_selector("button[class*='btn-success']").click() log.info("Entering country name on the check box i.e ind") self.driver.find_element_by_id("country").send_keys("ind") self.VerifyLinkPresenceWait("India") # expilicit wait in base class # wait = WebDriverWait(self.driver, 5) # wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India"))) self.driver.find_element_by_link_text("India").click() # self.driver.find_element_by_css_selector("div[class*='checkbox-primary']").click() # self.driver.find_element_by_css_selector("input[type='submit']").click() confirmpage = ConfirmPage(self.driver) # calling Page objects confirmpage.CheckBoxClick().click() confirmpage.SubmitButtonClick().click() sucessText = self.driver.find_element_by_css_selector( "div[class*='alert alert-success']").text assert "Thank you" in sucessText # print(sucessText) log.info(sucessText) self.driver.get_screenshot_as_file("screen.png")
def test_e2e(self): log = self.getLogger() homepage = HomePage(self.driver) log.info("Application started") homepage.shopItems().click() log.info("Shops Page started") checkout = CheckoutPage(self.driver) cards = checkout.cardTitles() log.info("Cards Selected") log.info(len(cards)) i = -1 for card in cards: i = i + 1 cardText = card.text if cardText == "Blackberry": checkout.addProduct()[i].click() checkout.checkOut().click() confirmPage = ConfirmPage(self.driver) confirmPage.CartPage() confirmPage.CountrySelect().send_keys("ind") self.verifyLinkPresence("India", 7) self.driver.find_element_by_link_text("India").click() confirmPage.CheckBoxTerms() confirmPage.submitButton() successText = self.driver.find_element_by_class_name( "alert-success").text assert "Success! Thank you!" in successText
def test_shop(self): log = self.getLogger() homepage = HomePage(self.driver) checkOutPage= homepage.shopItems() log.info("getting all the card title") cards = checkOutPage.getCardTitles() for card in cards: ReqProduct = card.find_element_by_xpath("div/h4/a").text if ReqProduct == "Blackberry": card.find_element_by_xpath("div[2]/button").click() checkOutPage.getCheckOut().click() log.info("Checking the selected products") assert checkOutPage.getProductCheck().text == "Blackberry" confirmPage = checkOutPage.getFinalCheckOut() log.info("Entering country Name as ind") confirmPage.getLocation().send_keys("ind") self.VerifyingText() self.driver.find_element_by_xpath("//div[@class='suggestions']/ul[1]").click() confirmPage = ConfirmPage(self.driver) confirmPage.getCheckBox().click() confirmPage.getPurchase().click() Subb = confirmPage.getAlert().text log.info("Text received from Application is "+ Subb) assert "Success! Thank you!" in Subb self.driver.get_screenshot_as_file("screenshot.png")
def getCheckoutButton(self): self.driver.find_element(*CheckOutPage.checkOutButton).click() confirmPage = ConfirmPage() return confirmPage
def getConfirmItem(self): # self.driver.find_element_by_css_selector("button[class*=btn-success]").click() self.driver.find_element(*CheckOutPage.confirmItem).click() confirmPage = ConfirmPage(self.driver) return confirmPage
def validateCheckoutButton(self): self.driver.find_element( *CheckOutPage.validate_checkout_button).click() confirm_page = ConfirmPage(self.driver) return confirm_page
def ClickSucessButton(self): # return self.driver.find_element(*CheckoutPage.Button1) self.driver.find_element(*CheckoutPage.Button1).click() confirmpage = ConfirmPage(self.driver) return confirmpage
def checkOutItems(self): self.driver.find_element( *CheckOutPage.checkOut).click() # Integration point confirmpage = ConfirmPage( self.driver) # and create the object of next class return confirmpage
def finalcheckout(self): # return self.driver.find_element(*CheckoutPage.confirmbtn) self.driver.find_element(*CheckoutPage.confirmbtn).click() confirmpage = ConfirmPage(self.driver) return confirmpage
def getConfirmCheckoutButton(self): self.driver.find_element(*CheckoutPage.confirmCheckoutButton).click() confirm_purchase_page = ConfirmPage(self.driver) return confirm_purchase_page
def test_e2e(self): # on creating HomePage driver object the HomePage.py constructor will be invoked homePage = HomePage(self.driver) homePage.shopItems().click() checkoutPage = CheckoutPage(self.driver) cards = checkoutPage.getCardTitles() confirmPage = ConfirmPage(self.driver) i = -1 for card in cards: i = i + 1 cardText = card.text print(cardText) if cardText == "Blackberry": checkoutPage.getCardFooter()[i].click() checkoutPage.confirmCheckoutButton().click() checkoutPage.checkOutItems().click() confirmPage.fillCountryField().send_keys("ind") element = WebDriverWait(self.driver, 10).until( expected_conditions.presence_of_element_located((By.LINK_TEXT, "India"))) confirmPage.chooseCountry().click() confirmPage.fillAgreement().click() confirmPage.confirmPurchase().click() textMatch = confirmPage.confirmGetText().text assert ("Success! Thank you!" in textMatch)
def addtocart(self): self.driver.find_element(*SelectionPage.Addtocart).click() confirmpage = ConfirmPage(self.driver) return confirmpage
def click_on_checkout_button(self): self.dr.find_element(*CheckoutPage.checkout_button).click() confirm_page = ConfirmPage(self.dr) return confirm_page
def checkout_action(self): self.driver.find_element(*CheckoutPage.checkout).click() confirm_page = ConfirmPage(self.driver) return confirm_page
def test_e2e(self): homePage = HomePage(self.driver) homePage.shopItems().click() checkOutPage = CheckoutPage(self.driver) products = checkOutPage.getCardTitles() for _ in products: product_Name = checkOutPage.productName if product_Name == 'Blackberry': checkOutPage.getCardFooter().click() checkOutPage.getCheckOutbutton().click() checkOutPage.getConfirmButton().click() confirmPage = ConfirmPage(self.driver) confirmPage.getCountry().send_keys('ind') wait = WebDriverWait(self.driver, 7) wait.until( expected_conditions.presence_of_element_located( (By.LINK_TEXT, "India"))) confirmPage.getselectCountry().click() confirmPage.getclickCountry().click() confirmPage.getsubmitbutton().click() success_text = confirmPage.getassertmsg().text assert 'Success' in success_text
def clickOnPrimaryButton(self): self.driver.find_element(*CheckOutPage.primaryButton).click() confirmPage = ConfirmPage(self.driver) return confirmPage
def ButtonItem(self): self.driver.find_element(*CheckoutPage.button_text).click() confirmPage = ConfirmPage(self.driver) return confirmPage
def checkOutItems(self): self.driver.find_element(*CheckOutPage.checkOut).click() confirmPage = ConfirmPage(self.driver) return confirmPage
def getFinalCheckOut(self): self.driver.find_element(*CheckOutPage.finalCheckOut).click() confirmPage = ConfirmPage(self.driver) return confirmPage
def test_NewConn(self, getData): log = self.getLogger() log.info("Entering Airtel URL") self.airtelurl() homepage = HomePage(self.driver) log.info("Click on broadband option") homepage.broadband().click() log.info("click on Buy New Connection option") selectionpage = homepage.buynewconnection() log.info("Click on Change City option") self.changecities() selectionpage.changecity().click() log.info("Enter City Name " + getData["City"]) selectionpage.othercity().send_keys(getData["City"]) log.info("Finally City name is selected") selectionpage.cityselect().click() log.info("List of all Monthly Rentals") rentals = selectionpage.rentalslist() try: for rental in rentals: log.info( "Selecting one by one Rental from Monthly Rentals list") MonthlyRental = rental.find_element_by_xpath("div[1]/p").text if MonthlyRental == "₹799": log.info("Selecting the required Rental Plan") BuyNow = rental.find_element_by_xpath("div[2]/span") self.driver.execute_script("arguments[0].click();", BuyNow) confirmpage = ConfirmPage(self.driver) log.info("Enter the Customer Name " + getData["Name"]) confirmpage.name().send_keys(getData["Name"]) log.info("Enter the Customer Mobile Number " + getData["Mobile"]) confirmpage.mobilenumber().send_keys(getData["Mobile"]) log.info("Click on Checkmark") confirmpage.checkmark().click() log.info("Enter the Customer Address " + getData["Address"]) confirmpage.address().send_keys(getData["Address"]) log.info("Click on Submit Option") confirmpage.submit().click() except StaleElementReferenceException: pass
def checkOutItems(self): self.driver.find_element( *CheckOutPage.checkOut).click() # btn btn-success confirmPage = ConfirmPage(self.driver) return confirmPage # This sets the object for the Confirmation Page