Beispiel #1
0
 def test_CheckoutListMatch(self):
     log = self.getLogger()
     self.checkoutPage = CheckoutPage(self.driver)
     productList = []
     expectedList = ['Carrot - 1 Kg', 'Cauliflower - 1 Kg']
     time.sleep(3)
     products = self.checkoutPage.getProducts()
     for product in products:
         productList.append(product.text)
     log.info(productList)
     assert productList == expectedList
Beispiel #2
0
    def test_DiscountCode(self):
        self.checkoutPage = CheckoutPage(self.driver)
        beforeDiscount = self.checkoutPage.getAmount().text
        self.checkoutPage.getPromoBox().send_keys("rahulshettyacademy")
        self.driver.implicitly_wait(6)
        self.checkoutPage.getPromoButton().click()
        self.verifyPromoButton("span.promoInfo")
        afterDiscount = self.checkoutPage.getDiscountAmount().text
        assert float(afterDiscount) < int(beforeDiscount)

        self.checkoutPage.getConfirmButton().click()
        self.confirmPage = ConfirmPage(self.driver)
        select = Select(self.confirmPage.getChooseCountry())
        select.select_by_visible_text("United Kingdom")
        self.confirmPage.getAgreeCheckbox().click()
        self.confirmPage.getProceedButton().click()
    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
Beispiel #4
0
    def test_first(self):

        self.driver.implicitly_wait(10)
        homepage = HomePage(self.driver)
        homepage.shopItems().click()
        # self.driver.find_element_by_css_selector("a[href*='/angularpractice/shop']").click()
        checkoutPage = CheckoutPage(self.driver)
        checkoutPage.Card().click()

        #driver.find_elements_by_xpath("//div[@class='card h-100']")

        products = self.driver.find_elements_by_xpath(
            "a[href*='/angularpractice/shop']")

        for product in products:
            productname = product.find_element_by_xpath("div/h4/a").text

        if productname == "Blackberry":
            product.find_element_by_xpath(
                "div/button[@class='btn btn-info']").click()

        self.driver.find_element_by_css_selector(
            "a[class*='btn-primary']").click()

        self.driver.find_element_by_xpath(
            "//button[@class='btn btn-success']").click()

        self.driver.find_element_by_css_selector("#country").send_keys("ind")
        self.VerifyLinkpresence("India")
        self.driver.find_element_by_xpath("//a[text()='India']").click()
        self.driver.find_element_by_xpath(
            "//div[@class='checkbox checkbox-primary']").click()
        self.driver.find_element_by_css_selector(
            "input[value*='Purchase']").click()

        print(
            self.driver.find_element_by_xpath(
                "//div[@class='alert alert-success alert-dismissible']").text)
Beispiel #5
0
    def test_freeDelivery(self):
        log = self.getLogger()
        homepage = HomePage(self.driver)
        homepage.getSearchBar().send_keys("callaway golf balls")
        time.sleep(3)
        balls = homepage.getCallawayBalls()
        # balls = self.driver.find_elements_by_xpath("//div[@class='name']")
        # print(len(balls))
        for ball in balls:
            if ball.text == "Callaway Warbird Plus 12 Ball Pack":
                ball.click()
                break

        checkoutpage = CheckoutPage(self.driver)
        chooseQuantity = checkoutpage.getQuantity()
        action = ActionChains(self.driver)
        action.double_click(chooseQuantity).perform()
        action.double_click(chooseQuantity).perform()
        chooseQuantity.send_keys("10")
        self.driver.implicitly_wait(5)

        try:
            popup = checkoutpage.getPopup()
            if popup.is_displayed():
                popup.click()

        except Exception as e:
            print(e)
        checkoutpage.getAddCart().click()
        deliverypage = checkoutpage.getConfirmCart()  #trigger point
        #self.driver.get_screenshot_as_file("FreeDelivery.png")
        subtotal = deliverypage.getTotalAmount().text[1:]
        log.info("Total amount of purchase is" + subtotal)
        deliveryAmount = deliverypage.getDeliveryCost().text[1:]
        log.info("Delivery amount is" + deliveryAmount)

        if float(subtotal) > 50:
            assert float(deliveryAmount) == 0
            print('amount is greater than 50 and 0 delivery fees is verified')
        else:
            print('amount is less then 50, so delivery fees is {}'.format(
                float(deliveryAmount)))

        log.info("Offer is working")
Beispiel #6
0
 def shopItems(self):
     self.driver.find_elements(*HomePage.shop).click()
     checkoutPage = CheckoutPage(self.driver)
     return CheckoutPage
 def shop(self):
     self.driver.find_element(*HomePage.shopButton).click()
     checkoutPage = CheckoutPage(self.driver)
     return checkoutPage
Beispiel #8
0
class TestGreenKart(BaseClass):
    @pytest.mark.regression
    def test_LogoDisplayed(self):
        log = self.getLogger()
        self.shopPage = ShopPage(self.driver)
        logo = self.shopPage.getLogo().text
        log.info("Logo is displayed as expected")
        assert logo == "GREENKART"

    @pytest.mark.regression
    def test_CartIsZero(self):
        self.shopPage = ShopPage(self.driver)
        items = self.shopPage.getCartItem().text
        assert items == "0"

        price = self.shopPage.getCartPrice().text
        assert price == "0"

    @pytest.mark.regression
    def test_CartPriceIncrease(self):
        self.shopPage = ShopPage(self.driver)
        searchBar = self.shopPage.getSearchBar()
        searchBar.send_keys("carrot")
        time.sleep(3)
        self.shopPage.getAddToCart().click()
        searchBar.clear()
        searchBar.send_keys("cauli")
        time.sleep(3)
        self.shopPage.getAddToCart().click()
        time.sleep(4)
        newItems = self.shopPage.getNewCartItems().text
        assert newItems == "2"

        newPrice = self.shopPage.getNewCartPrice().text
        assert newPrice > "0"

        self.shopPage.getCartIcon().click()
        time.sleep(3)
        self.shopPage.getCheckout().click()

    @pytest.mark.regression
    def test_CheckoutListMatch(self):
        log = self.getLogger()
        self.checkoutPage = CheckoutPage(self.driver)
        productList = []
        expectedList = ['Carrot - 1 Kg', 'Cauliflower - 1 Kg']
        time.sleep(3)
        products = self.checkoutPage.getProducts()
        for product in products:
            productList.append(product.text)
        log.info(productList)
        assert productList == expectedList

    @pytest.mark.regression
    def test_DiscountCode(self):
        self.checkoutPage = CheckoutPage(self.driver)
        beforeDiscount = self.checkoutPage.getAmount().text
        self.checkoutPage.getPromoBox().send_keys("rahulshettyacademy")
        self.driver.implicitly_wait(6)
        self.checkoutPage.getPromoButton().click()
        self.verifyPromoButton("span.promoInfo")
        afterDiscount = self.checkoutPage.getDiscountAmount().text
        assert float(afterDiscount) < int(beforeDiscount)

        self.checkoutPage.getConfirmButton().click()
        self.confirmPage = ConfirmPage(self.driver)
        select = Select(self.confirmPage.getChooseCountry())
        select.select_by_visible_text("United Kingdom")
        self.confirmPage.getAgreeCheckbox().click()
        self.confirmPage.getProceedButton().click()
Beispiel #9
0
 def shop_items(self):
     # self.driver.find_element_by_css_selector("a[href*='shop']").click()
     self.driver.find_element(
         *HomePage.shop).click()  # hvezdicka je tuple deserialization
     return CheckoutPage(self.driver)