Example #1
0
    def setUp(self):
        # Setting up how we want Firefox to run
        utility = Utility()
        browser = utility.get_browser()

        self.driver = self.startBrowser(browser)
        self.driver.maximize_window()
        self.driver.set_page_load_timeout(200)
        self.driver.implicitly_wait(120)
Example #2
0
    def setUp(self):
        # Setting up how we want Firefox to run
        utility = Utility()
        browser = utility.get_browser()

        # self.driver = webdriver.Firefox(executable_path=r'Drivers\geckodriver.exe')
        self.driver = self.startBrowser(browser)
        self.driver.maximize_window()
        self.driver.set_page_load_timeout(200)
        self.driver.implicitly_wait(120)
Example #3
0
    def get_item_total(self, auto_convert=True):

        text = self.get_text(CheckoutTwoPageLocators.LABEL_ITEM_TOTAL)
        if auto_convert:
            return Utility().convert_string_to_float(text)
        else:
            return
Example #4
0
 def getProducts_json(self):
     products = []
     data = Utility.read_json(Data.PRODUCTS_JSON_FILE)
     for item in data['products']:
         product = Product(item['name'], item['desc'], item['price'])
         products.append(product)
     return products
Example #5
0
 def read_products_from_json(sefl):
     products = []
     data = Utility.read_json(Data.PRODUCT_FILE)
     for item in data['products']:
         product = Product(item['name'], item['desc'], item['price'])
         products.append(product)
     return products
    def test_checkout_products(self):
        assertion = Assertion()
        login_page = LoginPage(self.driver)
        account = Account('standard_user', Data.PASSWORD)
        login_page.login(account)

        products = Data.get_products_json(self)
        products_page = ProductsPage(self.driver)

        for index in [1, 2, 3]:
            products_page.click_add_to_cart_button(index)

        products_page.click_badge_icon()
        cart_page = CartPage(self.driver)

        for index in [1, 2, 3]:
            actual_product = cart_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)

        cart_page.click_checkout()

        check_out_step_one_page = CheckOutStepOnePages(self.driver)
        check_out_step_one = CheckOutStepOne(Data.FIRSTNAME, Data.LASTNAME,
                                             Data.POSTALCODE)
        # check_out_step_one = CheckOutStepOne('a', 'b', '123')
        check_out_step_one_page.check_out_info(check_out_step_one)
        check_out_step_one_page.click_continue()

        check_out_step_two_page = CheckOutStepTwoPages(self.driver)
        total_price = 0.00
        for index in [1, 2, 3]:
            actual_product = check_out_step_two_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)
            total_price += Utility().multiple(actual_product.quantity,
                                              actual_product.price)

        self.assertEqual(total_price, check_out_step_two_page.get_item_total())

        actual_tax = total_price * 0.08004
        self.assertEqual(float("{:.2f}".format(actual_tax)),
                         check_out_step_two_page.get_tax())

        actual_total = total_price + actual_tax
        self.assertEqual(float("{:.2f}".format(actual_total)),
                         check_out_step_two_page.get_total())
        print(actual_total)

        check_out_step_two_page.click_finish()
Example #7
0
    def test_product2(self):
        products = Data.read_products_from_json(self)
        assertion = Assertion()

        login_page = LoginPage(self.driver)
        account = Account(Data.USERNAME_STANDARD_USER, Data.PASSWORD)
        login_page.login(account)
        product_page = ProductsPage(self.driver)

        for index in [1, 2, 3]:
            product_page.click_add_to_cart_button(index)

        product_page.click_badge_icon()
        cart_page = CartPage(self.driver)

        for index in [1, 2, 3]:
            actual_product = cart_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)

        cart_page.click_checkout_button()
        checkout_step_one_page = CheckoutStepOnePage(self.driver)
        checkout_step_one = CheckoutStepOne('a', 'b', 123)
        checkout_step_one_page.add_checkout_info(checkout_step_one)
        checkout_step_one_page.click_continue_button()

        checkout_step_two_page = CheckoutStepTwoPage(self.driver)
        total_price = 0.00
        for index in [1, 2, 3]:
            actual_product = checkout_step_two_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)
            print(actual_product.quantity)
            total_price += Utility().multiple(actual_product.quantity,
                                              actual_product.price)

        actual_tax = total_price * 0.08004
        self.assertEqual(float("{:.2f}".format(actual_tax)),
                         checkout_step_two_page.get_tax())

        actual_total = total_price + actual_tax
        self.assertEqual(float("{:.2f}".format(actual_total)),
                         checkout_step_two_page.get_total())

        print(checkout_step_two_page.get_item_total())
        print(checkout_step_two_page.get_tax())
        print(checkout_step_two_page.get_total())
        checkout_step_two_page.click_finish()
Example #8
0
 def get_tax(self, auto_convert=True):
     text = self.get_text(CheckoutTwoPageLocators.LABEL_TAX)
     if auto_convert:
         return Utility().convert_string_to_float(text)
     else:
         return
Example #9
0
 def get_total(self, auto_convert=True):
     text = self.get_text(CheckOutStepTwoLocators.LABEL_TOTAL)
     if auto_convert:
         return Utility().convert_string_to_float(text)
     else:
         return
Example #10
0
    def test_product(self):
        products = Data.getProducts_json(self)
        assertion = Assertion()

        login_page = LoginPage(self.driver)
        account = Account('standard_user', Data.PASSWORD)
        login_page.login(account)

        products_page = ProductsPage(self.driver)

        # for index, expected_product in enumerate(products, start=1):
        #     products_page.click_add_to_cart_button(index)
        for index in [1, 2, 3]:
            products_page.click_add_to_cart_button(index)

        products_page.click_badge_icon()
        cart_page = CartPage(self.driver)
        for index in [1, 2, 3]:
            actual_product = cart_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)
        # logging.info("Verify products from the cart page are the same with the selected products")
        # for index in [1, 2, 3]:
        #     assertion.compare_products(cart_page.get_product_info(index), products[index - 1])

        cart_page.click_checkout_button()

        checkout_step_one_page = CheckoutStepOnePage(self.driver)
        checkoutstepone = CheckoutStepOne('fname', 'lname', 'zipcode')
        checkout_step_one_page.add_checkout_info(checkoutstepone)
        checkout_step_one_page.click_continue()

        checkout_step_two_page = CheckoutStepTwoPage(self.driver)
        # compare selected products in cart page and checkout two page
        total_price = 0.00
        for index in [1, 2, 3]:
            actual_product = checkout_step_two_page.get_product_info(index)
            expected_product = products[index - 1]
            assertion.compare_products(actual_product, expected_product)
            print(actual_product.quantity)
            total_price += Utility().multiple(actual_product.quantity, actual_product.price)

        payment_info = checkout_step_two_page.get_payment_info()
        shipping_info = checkout_step_two_page.get_shipping_info()
        self.assertEqual('SauceCard #31337', payment_info)
        self.assertEqual('FREE PONY EXPRESS DELIVERY!', shipping_info)

        # print(checkout_step_two_page.get_item_total())
        # print(checkout_step_two_page.get_tax())
        # print(checkout_step_two_page.get_total())

        print(total_price)
        self.assertEqual(total_price, checkout_step_two_page.get_item_total())

        actual_tax = total_price * 0.08004
        self.assertEqual(float("{:.2f}".format(actual_tax)), checkout_step_two_page.get_tax())
        print(float("{:.2f}".format(actual_tax)))

        actual_total = total_price + actual_tax
        self.assertEqual(float("{:.2f}".format(actual_total)), checkout_step_two_page.get_total())
        print(float("{:.2f}".format(actual_total)))
Example #11
0
    def setUp(self):
        utility = Utility()
        browser = utility.get_browser()

        self.driver = self.startBrowser(browser)
        self.driver.maximize_window()
Example #12
0
 def setUp(self):
     # Setting up how we want Chrome to run
     utility = Utility()
     browser = utility.get_browser()
     self.driver = self.startBrowser(browser)
     self.driver.maximize_window()