def test_guest_can_add_product_to_basket(browser, url): new_link = f"http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/?promo=offer{url}" page = ProductPage(browser, new_link) page.open() page.click_add_to_cart_button(browser) page.check_that_product_is_added() page.check_that_price_is_correct()
def test_user_can_add_product_to_cart(self, browser): page = ProductPage(browser, product_link) page.open() page.should_be_add_to_cart_button() page.add_to_cart() page.product_added() page.product_price()
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser): link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/" page = ProductPage(browser, link) page.open() page.go_to_basket_page() basket_page = BasketPage(browser, browser.current_url) basket_page.should_be_empty()
def test_guest_can_add_product_to_cart(browser, link): page = ProductPage(browser, link) page.open() page.should_be_add_to_cart_button() page.add_to_cart() page.product_added() page.product_price()
def test_guest_cant_see_product_in_cart_opened_from_product_page(browser): page = ProductPage(browser, product_link) page.open() page.go_to_cart_page() cart_page = CartPage(browser, browser.current_url) cart_page.cart_is_empty() cart_page.empty_cart_subtitle()
def test_guest_cant_see_success_message_after_adding_product_to_basket( browser): link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/" page = ProductPage(browser, link, timeout=0) page.open() page.add_product_to_basket() page.is_not_succsess_message_present()
def test_guest_can_go_to_login_page_from_product_page(browser): link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/" page = ProductPage(browser, link) page.open() page.should_be_login_link() page.go_to_login_page() login_page = LoginPage(browser, browser.current_url) login_page.should_be_login_page()
def add_product(get_driver, go_to_product_page, product_dataset): """fixture to add product test""" product_page = ProductPage(get_driver, go_to_product_page) product_page.navigate() product_name, product_meta_tag_title, product_model = product_dataset product_page.add_product(product_name, product_meta_tag_title, product_model) current_result = product_page.get_alert() expected_result = "Success: You have modified products!" return expected_result, current_result
def delete_product(add_waits, go_to_product_page, product_dataset_more): """fixture to delete product test""" product_page = ProductPage(add_waits, go_to_product_page) product_page.navigate() product_name, product_meta_tag_title, product_model = product_dataset_more product_page.add_product(product_name, product_meta_tag_title, product_model) product_page.delete_product() current_result = product_page.get_alert() expected_result = "Success: You have modified products!" return expected_result, current_result
def run(self): if WATCH_MODE: self.watch_release() option = Options() if PROXY: option.add_argument('--proxy-server=http://%s' % PROXY) driver = webdriver.Chrome(executable_path=CHROME_DRIVER_PATH, options=option) driver.set_window_position(self.window_position_x, self.window_position_y) driver.set_window_size(self.window_width, self.window_height) shop_all_page = ShopAllPage(driver) shop_all_page.open() for i, product in enumerate(self.products): if not self.check_product_existance(product): logging.info('Product "' + product['name'] + '" not found') continue elif not self.check_stock(product): logging.info('Product "' + product['name'] + '" is sold out') continue else: logging.info('Product "' + product['name'] + '" is in stock') shop_all_page.click_product(product['href']) product_page = ProductPage(shop_all_page.driver) if product['size'] is not None: product_page.select_size(product['size']) product_page.add_to_cart() sleep(ADD_TO_CART_DELAY) logging.info(f'Product "{product["name"]}" is added to cart') if i == len(self.products) - 1: product_page.checkout() checkout_page = CheckoutPage(product_page.driver) checkout_page.fillout() logging.info('Checkout info filled out') # if AUTO_PROCESS_PAYMENT: # checkout_page.process_payment() else: product_page.shop_all() shop_all_page = ShopAllPage(product_page.driver) sleep(MANUAL_ADJUSTMENT_TIME)
def test_add_product_to_cart_from_product_page(browser): QTY = 2 product_page = ProductPage(browser) product_page.open() product_price = product_page.get_product_price() product_page.set_quantity(QTY) product_page.add_to_cart() assert Alert(browser).alert top_menu = TopMenu(browser) cart_total_amount = top_menu.get_cart_text() product_price = float(product_price.replace("$", "")) assert str(product_price * QTY) in cart_total_amount
def test_open_product_card_from_catalog(browser): CATEGORY = 'Tablets' category_page = CategoriesPage(browser) category_page.open() NavigationBar(browser).open_page() NavigationBar(browser).open_section_by_name(CATEGORY) section_title = category_page.get_category_name() assert section_title == CATEGORY product_name = category_page.get_product_name_in_minicard() print("product_name", product_name) category_page.open_product_card() product_title = ProductPage(browser).get_product_name() assert product_title == product_name
def test_guest_should_see_login_link_on_product_page(browser): link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/" page = ProductPage(browser, link) page.open() page.should_be_login_link()
def test_guest_can_go_to_login_page_from_product_page(browser): new_link = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the-city-and-the-stars_95/" page = ProductPage(browser, new_link) page.open() page.go_to_login_page()
def test_guest_can_add_product_to_basket(browser): link = "http://selenium1py.pythonanywhere.com/catalogue/the-shellcoders-handbook_209/?promo=newYear" page = ProductPage(browser, link) page.open() page.add_product_to_basket()
def test_guest_can_add_product_to_basket_bug(browser, link): page = ProductPage(browser, link) page.open() page.add_product_to_basket()
def test_guest_can_go_to_login_page_from_product_page(browser): page = ProductPage(browser, product_link) page.open() page.go_to_login_page()
def test_guest_should_see_login_link_on_product_page(browser): page = ProductPage(browser, product_link) page.open() page.should_be_login_link()
def test_message_disappeared_after_adding_product_to_cart(browser): page = ProductPage(browser, product_link) page.open() page.add_to_cart() page.success_message_should_dissapear()
def test_guest_cant_see_success_message(browser): page = ProductPage(browser, product_link) page.open() page.should_not_be_success_message()
def test_message_disappeared_after_adding_product_to_basket(browser): page = ProductPage(browser, link) page.open() page.click_add_to_cart_button(browser) page.should_disappear()
def test_guest_cant_see_product_in_basket_opened_from_product_page(browser): page = ProductPage(browser, link) page.open() page.go_to_cart() basket_page = BasketPage(browser, browser.current_url) basket_page.should_be_empty_basket()
def test_user_can_add_product_to_basket(self, browser): page = ProductPage(browser, link) page.open() page.click_add_to_cart_button(browser) page.check_that_product_is_added() page.check_that_price_is_correct()
def test_guest_cant_see_success_message_after_adding_product_to_basket( browser): page = ProductPage(browser, link) page.open() page.click_add_to_cart_button(browser) page.should_not_be_success_message()
def test_guest_cant_see_success_message_after_adding_product_to_cart(browser): page = ProductPage(browser, product_link) page.open() page.add_to_cart() page.should_not_be_success_message()
def test_user_cant_see_success_message(self, browser): page = ProductPage(browser, link) page.open() page.should_not_be_success_message()