def test_view_large_product_image(self):
        # Feature: Chi tiết sản phẩm; Title: Kiểm tra chức năng View Large

        homePage = HomePage(self.driver)
        homePage.click_product_image(1)  # Click a image of the first product
        productDetailPage = ProductDetailPage(self.driver)
        productDetailPage.click_big_page()
        self.get_result(productDetailPage)

        # Feature: Chi tiết sản phẩm; Title: Kiểm tra chức năng View Large; Preconditional: Click vào button [Close] trên ảnh

        productDetailPage.click_close_view_larger()
        productDetailPage.click_view_larger_button()
        self.get_result(productDetailPage)

        # Feature: Chi tiết sản phẩm; Title: Add to cart với Quantity =0
        productDetailPage.click_close_view_larger()
        #Set quantity of product
        productDetailPage.set_product_quantity(0)
        productDetailPage.click_add_to_cart()
        null_quantity_message = productDetailPage.get_null_quantity_message()
        self.assertEqual('Null quantity.', null_quantity_message,
                         "Null message is not match")

        # Feature: Chi tiết sản phẩm; Title: Add to cart với Quantity > 0
        productDetailPage.click_close_view_larger()
        productDetailPage.set_product_quantity(1)
        product_title = productDetailPage.getProductTitle(
        )  # Get the title of the product
        productDetailPage.click_add_to_cart()  # Adding product to cart
        add_to_cart_successfully_message = productDetailPage.get_add_to_cart_successfully_message(
        )
        self.assertEqual('Product successfully added to your shopping cart',
                         add_to_cart_successfully_message,
                         'Message is not match!')
        productDetailPage.click_close_add_to_cart_successfully_message()
        productDetailPage.click_cart_button()
        checkOutPage = CheckOutPage(self.driver)
        product_title_cart = checkOutPage.get_product_title(1)
        product_quantity_cart = checkOutPage.get_product_quantity(1)
        self.assertEqual(product_title, product_title_cart,
                         "Product title is not match!")
        self.assertEqual('1', product_quantity_cart,
                         'Product price is not match!')
Esempio n. 2
0
    def test_view_large_product_image(self, browser):
        # Thiết lập trình duyệt Chrome, Firefox
        if browser == 'chrome':
            self.driver = webdriver.Chrome(
                executable_path=
                r'C:\Drivers\chromedriver_win32\chromedriver.exe')
            self.driver.maximize_window()
            self.driver.get(self.baseURL)
            self.driver.implicitly_wait(5)

        else:
            self.driver = webdriver.Firefox(
                executable_path=
                r'C:\Drivers\geckodriver-v0.29.0-win64\geckodriver.exe')
            self.driver.maximize_window()
            self.driver.get(self.baseURL)
            self.driver.implicitly_wait(5)

            # Feature: Chi tiết sản phẩm; Title: Kiểm tra chức năng View Large

        homePage = HomePage(self.driver)
        homePage.click_product_image(1)  # Click a image of the first product
        productDetailPage = ProductDetailPage(self.driver)
        productDetailPage.click_big_page()
        self.get_result(productDetailPage)

        # Feature: Chi tiết sản phẩm; Title: Kiểm tra chức năng View Large; Preconditional: Click vào button [Close] trên ảnh

        productDetailPage.click_close_view_larger()
        productDetailPage.click_view_larger_button()
        self.get_result(productDetailPage)

        # Feature: Chi tiết sản phẩm; Title: Add to cart với Quantity =0
        productDetailPage.click_close_view_larger()
        # Set quantity of product
        productDetailPage.set_product_quantity(0)
        productDetailPage.click_add_to_cart()
        null_quantity_message = productDetailPage.get_null_quantity_message()
        self.assertEqual('Null quantity.', null_quantity_message,
                         "Null message is not match")

        # Feature: Chi tiết sản phẩm; Title: Add to cart với Quantity > 0
        productDetailPage.click_close_view_larger()
        productDetailPage.set_product_quantity(1)
        product_title = productDetailPage.getProductTitle(
        )  # Get the title of the product
        productDetailPage.click_add_to_cart()  # Adding product to cart
        add_to_cart_successfully_message = productDetailPage.get_add_to_cart_successfully_message(
        )
        self.assertEqual('Product successfully added to your shopping cart',
                         add_to_cart_successfully_message,
                         'Message is not match!')
        productDetailPage.click_close_add_to_cart_successfully_message()
        productDetailPage.click_cart_button()
        checkOutPage = CheckOutPage(self.driver)
        product_title_cart = checkOutPage.get_product_title(1)
        product_quantity_cart = checkOutPage.get_product_quantity(1)
        self.assertEqual(product_title, product_title_cart,
                         "Product title is not match!")

        self.assertEqual('1', product_quantity_cart,
                         'Product price is not match!')
        time.sleep(5)
        self.driver.quit()