def driver(init_driver): driver = init_driver driver.get( 'http://demo.opencart.com/index.php?route=product/product&product_id=47' ) # driver.get(f'{BASE_HOST}/index.php?route=product/product&product_id=47') (ProductPage(driver).add_to_cart().goto_cart().goto_checkout()) yield driver
def test_add_product_to_cart(login_setup): driver = login_setup with pytest.allure.step('Testing adding products to the Cart'): HomePage(driver)\ .click_nav_desktops_mac()\ .goto_mac_desktops()\ .add_to_cart() assert (Outputs.TEXT_ALERT_PRODUCT_ADD in ProductPage(driver).get_product_add_confirmation())
def test_guest_can_open_product_picture(self, browser): """open product detail and maximize the picture""" home_page = HomePage(browser) home_page.search_for("t-shirt") # enter search term into search field and submit search = SearchResults(browser) # the search result are loaded product_title = search.get_product_title(1) # get name of the first search result search.open_product_page(1) # click search result No1 product_page = ProductPage(browser) product_page.product_title_should_be_correct(product_title) # compare expected title with the one on the page product_page.open_product_picture() # click the main picture product_page.close_product_picture() # click "X" on the main picture
def test_add_goods_to_cart(): with pytest.allure.step('Testing adding goods to cart functional'): logger.info('Start testing add goods to cart function') page = HomePage(driver).logging() page = LoginPage(driver).input_password().input_email().login() page = HomePage(driver).select_mac_product() page = ProductPage(driver).add_mac_to_cart().driver.implicitly_wait(5) logger.info('Checking proper work of adding goods to cart') success_text = page.driver.find_element_by_class_name('alert') assert 'Success: You have added' in success_text.text logger.info('Work of adding goods to cart function has been checked')
def test_guest_can_add_product_to_cart(self, browser): """search for product, open product details and add product to cart""" home_page = HomePage(browser) home_page.search_for("t-shirt") # enter search term into search field and submit search = SearchResults(browser) # the search result are loaded search.open_product_page(1) # click search result No1 product_page = ProductPage(browser) product_name = product_page.product_name # get the name product on the product page summary = product_page.add_to_cart() # click "Add to cart" # check if the names are the same, count should be as expected summary.product_is_added_to_cart(product_name, 1) summary.close_cart_summary() # close the short cart summary product_page = ProductPage(browser) # count of products in the shopping cart should be as expected # without opening the shopping cart product_page.number_of_products_in_cart_should_be_as_expected(1)
def test_purchase(self, wrap): # precondition driver = self.driver page = HomePage(driver) page.go_to_product() page = ProductPage(driver) page.add_to_cart() page.go_to_cart() # page.cart.click() page = CartPage(driver) page.go_to_checkout() page = CheckoutPage(driver) page.checkout_options()
def __init__(self, headless, url): options: Options = Options() if headless: options.add_argument("--headless") self.url = url chrome_options = webdriver.ChromeOptions() self.driver = webdriver.Remote( command_executor="http://localhost:4444/wd/hub", options=chrome_options) self.login = LoginPage(self) self.product_list = ProductList(self) self.product = ProductPage(self) self.cart = CartPage(self) self.checkout = CheckoutPage(self) self.overview = OverviewPage(self) self.order_confirmation = OrderConfirmationPage(self) self.left_menu = LeftMenuPage(self) self.cart_icon = CartIconElement(self)
from selenium import webdriver from pages.product import ProductPage PAGE_URL = "http://selenium1py.pythonanywhere.com/en-gb/catalogue/the" \ "-shellcoders-handbook_209/?promo=newYear " driver = webdriver.Firefox() product_page = ProductPage(driver, PAGE_URL) product_page.btn_add_to_basket.click() product_page.solve_quiz_and_get_code()
def driver(init_driver): driver = init_driver driver.get(URL) (ProductPage(driver).add_to_cart().goto_cart().goto_checkout()) yield driver HomePage(driver).logout()