Esempio n. 1
0
    def test_add_to_cart_no_popup(self):
        # 1- Open product page and assert page is opened
        MenuObject.click_list_of_brands(self, 'CEP')
        self.assertIn('Items', ProductPage.get_total_item_lable_text(self))

        # 2- check all page images loaded successfully
        ProductPage.validate_product_page_images(self)
        # add_to_cart_without_option_popup = ProductPage.get_not_optional_btn(self)

        # 3- Get value of cart label
        old_cart_value = ProductPage.get_cart_count_label_value(self)
        old_int_value = int(old_cart_value[7])  # get the 8th char

        # 4- Click add to cart
        ProductPage.click_add_to_cart(self)
        # 5- wait till ifram appeared to ensure new cart value
        alert = WebDriverWait(self.driver, 15).until(
            EC.visibility_of_element_located((By.CLASS_NAME, 'message-alert')))
        # get text from alert
        alert_text = alert.text

        # assert alert text
        self.assertIn('was added to your shopping cart', alert_text)

        # 5- Check cart value incremented by 1
        new_cart_value = ProductPage.get_cart_count_label_value(self)
        new_int_value = int(new_cart_value[7])
        expected_cart_value = old_int_value + 1

        self.assertEqual(new_int_value, expected_cart_value)
    def test_add_to_cart_no_popup(self):
        # 1- Open product page and assert page is opened
        MenuObject.click_list_of_brands(self,'CEP')
        self.assertIn('Items', ProductPage.get_total_item_lable_text(self))

        # 2- check all page images loaded successfully
        ProductPage.validate_product_page_images(self)
       # add_to_cart_without_option_popup = ProductPage.get_not_optional_btn(self)

        # 3- Get value of cart label
        old_cart_value = ProductPage.get_cart_count_label_value(self)
        old_int_value = int(old_cart_value[7])# get the 8th char

        # 4- Click add to cart
        ProductPage.click_add_to_cart(self)
        # 5- wait till ifram appeared to ensure new cart value
        alert = WebDriverWait(self.driver, 15).until(
                    EC.visibility_of_element_located((By.CLASS_NAME,'message-alert')))
        # get text from alert
        alert_text = alert.text

        # assert alert text
        self.assertIn('was added to your shopping cart',alert_text)

        # 5- Check cart value incremented by 1
        new_cart_value = ProductPage.get_cart_count_label_value(self)
        new_int_value = int(new_cart_value[7])
        expected_cart_value = old_int_value +1

        self.assertEqual(new_int_value,expected_cart_value)
    def test_add_to_cart(self):
        # 1- Open product page and assert page is opened
        MenuObject.click_list_of_brands(self,'CEP')
        self.assertIn('Items', ProductPage.get_total_item_lable_text(self))
        # 2- check all page images loaded successfully
        ProductPage.validate_product_page_images(self)
        # 3- Get value of cart label
        old_cart_value = ProductPage.get_cart_count_label_value(self)
        old_int_value = int(old_cart_value[7])# get the 8th char
        # get list of all add to cart buttons
        add_to_cart_with_option_popup = ProductPage.get_option_btn(self)

        for x in add_to_cart_with_option_popup:
            x.click()
            #wait till popup displayed
            WebDriverWait(self.driver, 20).until(
                EC.visibility_of_element_located((By.XPATH, "//form[@id='product_addtocart_form']/..")))#get parent element of the form tag
            #insert form data
            ProductDetailsPopUP.set_color_value(self)
            ProductDetailsPopUP.set_size_value(self)
            ProductDetailsPopUP.set_quantity_value(self)
            ProductDetailsPopUP.click_add_to_cart_btn(self)
            self.assertIn('was added to your shopping cart',CartPage.get_sucess_message(self))
            #CartPage.click_checkout_button(self)
            break
            #MenuObject.click_list_of_brands(self,'CEP')
            #CartPage.click_continue_shopping(self)

        # 5- Check cart value incremented by 1
        new_cart_value = ProductPage.get_cart_count_label_value(self)
        new_int_value = int(new_cart_value[7])
        expected_cart_value = old_int_value +2 # incremented by value added in the quantity field
        self.assertEqual(new_int_value,expected_cart_value)
Esempio n. 4
0
    def test_add_to_cart(self):
        # 1- Open product page and assert page is opened
        MenuObject.click_list_of_brands(self, 'CEP')
        self.assertIn('Items', ProductPage.get_total_item_lable_text(self))
        # 2- check all page images loaded successfully
        ProductPage.validate_product_page_images(self)
        # 3- Get value of cart label
        old_cart_value = ProductPage.get_cart_count_label_value(self)
        old_int_value = int(old_cart_value[7])  # get the 8th char
        # get list of all add to cart buttons
        add_to_cart_with_option_popup = ProductPage.get_option_btn(self)

        for x in add_to_cart_with_option_popup:
            x.click()
            #wait till popup displayed
            WebDriverWait(self.driver, 20).until(
                EC.visibility_of_element_located(
                    (By.XPATH, "//form[@id='product_addtocart_form']/.."
                     )))  #get parent element of the form tag
            #insert form data
            ProductDetailsPopUP.set_color_value(self)
            ProductDetailsPopUP.set_size_value(self)
            ProductDetailsPopUP.set_quantity_value(self)
            ProductDetailsPopUP.click_add_to_cart_btn(self)
            self.assertIn('was added to your shopping cart',
                          CartPage.get_sucess_message(self))
            #CartPage.click_checkout_button(self)
            break
            #MenuObject.click_list_of_brands(self,'CEP')
            #CartPage.click_continue_shopping(self)

        # 5- Check cart value incremented by 1
        new_cart_value = ProductPage.get_cart_count_label_value(self)
        new_int_value = int(new_cart_value[7])
        expected_cart_value = old_int_value + 2  # incremented by value added in the quantity field
        self.assertEqual(new_int_value, expected_cart_value)