def test_SuitableProductDetail(self):
     homePage = HomePage(self.driver)
     productDetail = ProductDetailPage(self.driver)
     # Type keywords
     homePage.setSearchKeyword(self.keyword)
     # Get all suggest keywords
     suggestKeyWords_list = homePage.getAllSuggestKeyWords()
     suggestKeyword_index = 0
     for suggestKeyword in suggestKeyWords_list:
         suggestKeyword_index += 1
         # Get single suggest keyword
         suggestKeyword_text = homePage.getSuggestKeyWord(
             suggestKeyword_index)
         # Click single suggest keyword
         homePage.clickSuggestKeyWord(suggestKeyword_index)
         # Get the title of product in product detail page
         productTitle = productDetail.getProductTitle()
         # Compare the title of product to the suggest keyword clicked
         self.assertIn(productTitle, suggestKeyword_text,
                       'Product tille is not match!')
         # Typing keyword again after compare the previous result
         if suggestKeyword_index < len(suggestKeyWords_list):
             homePage.setSearchKeyword(self.keyword)
         else:
             break
Esempio n. 2
0
    def test_share_to_twitter(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: Share to TWitter
        homePage = HomePage(self.driver)
        homePage.click_product_image(1)
        productDetailPage = ProductDetailPage(self.driver)
        productDetailPage.click_tweet()
        time.sleep(5)
        window_after = self.driver.window_handles[1]
        self.driver.switch_to.window(window_after)
        self.assertTrue(productDetailPage.login_twitter('vicvu8', '123456aA@'))

        time.sleep(5)
        self.driver.quit()
 def test_share_to_twitter(self):
     # Feature: Chi tiết sản phẩm; Title: Share to TWitter
     homePage = HomePage(self.driver)
     homePage.click_product_image(1)
     productDetailPage = ProductDetailPage(self.driver)
     productDetailPage.click_tweet()
     time.sleep(5)
     window_after = self.driver.window_handles[1]
     self.driver.switch_to.window(window_after)
     self.assertTrue(productDetailPage.login_twitter('vicvu8', '123456aA@'))
 def test_write_a_comment(self):
     # Feature: Chi tiết sản phẩm; Title: Write a comment
     emailSignIn = '*****@*****.**'
     passwordSignIn = '123456'
     homePage = HomePage(self.driver)
     homePage.clickSignIn()
     loginPage = LoginPage(self.driver)
     loginPage.sign_in(emailSignIn, passwordSignIn)
     self.driver.implicitly_wait(10)
     self.driver.get(self.baseURL)
     homePage.click_product_image(1)
     productDetailPage = ProductDetailPage(self.driver)
     productDetailPage.leave_review('Comment', 'Good')
     send_review_message = productDetailPage.get_send_review_message()
     self.assertEqual(
         'Your comment has been added and will be available once approved by a moderator',
         send_review_message, "Send review unsuccessfully")
Esempio n. 5
0
 def test_promotion_product(self):
     # Feature: Mua hàng; Title: Mua đồ khuyến mãi
     # self.driver.get(self.baseURL)
     # time.sleep(3)
     homePage = HomePage(self.driver)
     checkOutPage = CheckOutPage(self.driver)
     totalProducts = homePage.getAllProducts()
     # Click product which has percent reduction is 20
     homePage.click_product_belongs_to_reduction(20)
     # Click add to cart
     product_detail_page = ProductDetailPage(self.driver)
     product_detail_page.click_add_to_cart()
     # Click Proceed to checkout
     homePage.click_proceed_to_checkout()
     checkOutPage.proceed_to_checkout(self.emailSignIn, self.passwordSignIn)
     completeMessage = checkOutPage.get_complete_message()
     self.assertEqual('Your order on My Store is complete.',
                      completeMessage, "Proceed to checkout unsuccesfully")
    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!')
 def test_send_to_a_friend(self):
     # Feature: Chi tiết sản phẩm; Title:Send to friend
     homePage = HomePage(self.driver)
     homePage.click_product_image(1)
     productDetailPage = ProductDetailPage(self.driver)
     productDetailPage.click_send_to_a_friend()
     productDetailPage.set_friend_name('Alexander')
     productDetailPage.set_friend_email('*****@*****.**')
     productDetailPage.send_to_a_friend()
     send_to_a_friend_message = productDetailPage.get_send_to_a_friend_message(
     )
     self.assertEqual('Your e-mail has been sent successfully',
                      send_to_a_friend_message,
                      "Send to a friend unsuccessfully!")
Esempio n. 8
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()