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_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!")
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")
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_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()