예제 #1
0
    def test_e2e(self):
        log = self.getLogger()
        nameList = ['Blackberry']
        cartList = []
        homePage = HomePage(self.driver)
        # homePage.shopItems().click()
        Checkoutpage = homePage.shopItems()
        # here we can use driver in two ways one is passing the setup fixture into test case and also by defining request.cls.driver = driver then to self.driver
        # you can only access the class driver is with the self
        # carts = self.driver.find_element_by_css_selector(".card-title a")
        # Checkoutpage = checkOutPage(self.driver)
        carts = Checkoutpage.getCarts()
        i = -1
        for cart in carts:
            i = i + 1
            # name = cart.find_element_by_xpath("//div//h4//a")[i].text
            name = cart.text
            log.info(name)
            print(name)
            if name == "Blackberry":
                # cart.find_elements_by_xpath("div//button").click()
                Checkoutpage.getCardFooter()[i].click()
        # self.driver.find_element_by_css_selector(".btn-primary").click()
        Checkoutpage.goToCheckOutButton().click()
        # items = self.driver.find_elements_by_xpath("//div[@class='media']//div//h4//a")
        items = Checkoutpage.getItems()
        for item in items:
            cartList.append(item.text)
        print(cartList)
        log.info(cartList)

        assert nameList == cartList

        # self.driver.find_element_by_css_selector(".btn-success").click()
        # Checkoutpage.clickOnCheckOut().click()
        Confirmpage = Checkoutpage.clickOnCheckOut()
        # self.driver.find_element_by_id("country").send_keys("Ind")
        # Confirmpage = confirmPage(self.driver)
        log.info("Passing the keyword as Ind ")
        Confirmpage.getCountry().send_keys("Ind")
        # wait = WebDriverWait(self.driver, 7)
        # wait.until(expected_conditions.presence_of_element_located((By.LINK_TEXT, "India")))
        self.verifyLinkPresence("India")
        # self.driver.find_element_by_link_text("India").click()
        Confirmpage.getSelectCountry().click()
        # self.driver.find_element_by_css_selector("[for=checkbox2]").click()
        Confirmpage.checkBox().click()
        # self.driver.find_element_by_css_selector("[type='submit']").click()
        Confirmpage.purchaseClick().click()
        # successMessage = self.driver.find_element_by_class_name("alert-success").text
        successMessage = Confirmpage.successMessage().text
        print(successMessage)
        log.info("Success message will be " + successMessage)
        assert "Success!" in successMessage

        self.driver.get_screenshot_as_file("photo.png")
예제 #2
0
    def test_e2e(self):
        log = self.getLogger()
        homepage = HomePage(self.driver)
        objects = homepage.shopItems()
        cards = objects.getCardTitles()
        log.info("Getting all card titles.")
        i = -1
        for card in cards:
            i = i + 1
            cardText = card.text
            log.info(cardText)
            if cardText == "Blackberry":
                objects.getCardFooter()[i].click()

        time.sleep(2)

        checkout_items = objects.gotoCheckout(
        )  # confirm items and transit checkout page

        phones = checkout_items.Items()

        for phone in phones:
            if phone.text == "Blackberry":
                print("Asserted")
                break

        price_info = checkout_items.getPrices()
        for element in price_info:
            log.info(element.text[3:])

        confirm = checkout_items.confirmCheckout(
        )  # confirm checkout and transit to next page

        assert "location" in confirm.getLabels().text
        log.info("Entering country name as 'In' for searching India")
        confirm.getDropdown().send_keys("In")
        self.verifyLinkPresence("India")
        log.info("Selecting country as India")

        # confirm.waitCountry().click()
        self.driver.find_element_by_link_text("India").click()
        time.sleep(2)
        self.driver.execute_script("arguments[0].click();",
                                   confirm.getCheckbox())
        time.sleep(2)
        assert confirm.getCheckbox().is_enabled()

        self.driver.execute_script("arguments[0].click();",
                                   confirm.getSubmitButton())
        time.sleep(1)
        log.info("Text received is: " + confirm.getSuccessMessage().text)

        assert "Success! Thank you" in confirm.getSuccessMessage().text
예제 #3
0
    def test_e2e(self):
        log = self.getLogger()

        homePage = HomePage(self.driver)

        # Below is removed to homePage.py
        # homePage.shopItems().click()

        checkOutPage = homePage.shopItems()
        # checkOutPage is moved to homePage.py
        # checkOutPage = CheckOutPage(self.driver)

        log.info("Getting all the card titles")

        cards = checkOutPage.getCardTitle()
        i = -1
        for card in cards:
            i = i + 1
            cardText = card.text
            log.info(cardText)
            if cardText == "Blackberry":
                checkOutPage.getCardFooter()[i].click()

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

        # Below is removed to checkOutPage.py
        # checkOutPage.checkOutItems().click()
        # self.driver.find_element_by_xpath("//button[@class='btn btn-success']").click()

        confirmPage = checkOutPage.checkOutItems()
        # checkOutPage is moved to checkOutPage.py
        # confirmPage = ConfirmPage(self.driver)

        log.info("Entering country name as ind")

        confirmPage.getCountry().send_keys("ind")
        # self.driver.find_element_by_id("country").send_keys("ind")

        self.verifyLinkPresence("India")
        # Below is removed to BaseClass.py
        # element = WebDriverWait(self.driver, 10).until(
        #     EC.presence_of_element_located((By.LINK_TEXT, "India"))
        # )

        confirmPage.getCountryConfirmed().click()
        # self.driver.find_element_by_link_text("India").click()

        confirmPage.getCheckBox().click()
        # self.driver.find_element_by_xpath("//div[@class='checkbox checkbox-primary']").click()

        confirmPage.getSubmitBtn().click()
        # self.driver.find_element_by_css_selector("[type='submit']").click()

        textMatch = confirmPage.getSuccessText().text
        # 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)
        assert ("Success! Thank you!" in textMatch)
        assert ("Success! Thank you!" in textMatch)
        assert ("Success! Thank you!" in textMatch)