def test004(start_browser): """ Test type - positive Create new product with 3 img :param start_browser: browser run """ with allure.step('Running test case'): driver, proxy = start_browser images_names = ("1", "2", "3") jpg_names = list() for name in images_names: jpg_names.append(str(name) + ".jpg") with allure.step('Authorize as admin'): authorize_as_admin(driver, login="******", password="******") with allure.step('Add new product with image'): add_new_product_with_images( driver, product_name="Test product", meta_tag="Test meta tag", model="Test model", images_path="/home/vasiliev_va/Downloads/special/", file_names=jpg_names) with allure.step('Check product'): ProductPage.check_images_names(driver, images_names) with allure.step('Delete image and product'): delete_images_from_opencart(driver, file_names=jpg_names) MainPage.open_product_catalog(driver) MainPage.click_product_button(driver) filter_products_by_name(driver, product_name="Test product") delete_all_products(driver) ProductPage.accept_product_delete(driver) proxy_logging(proxy)
def test002(start_browser): """ Test type - positive Delete product :param start_browser: browser run """ with allure.step('Running test case'): driver, proxy = start_browser with allure.step('Authorize as admin'): authorize_as_admin(driver, login="******", password="******") with allure.step('Add new product'): add_new_product(driver, product_name="Test product", meta_tag="Test meta tag", model="Test model") with allure.step('Delete product'): filter_products_by_name(driver, product_name="Test product") delete_all_products(driver) ProductPage.accept_product_delete(driver) with allure.step('Deletion check'): filter_products_by_name(driver, product_name="Test product") products = ProductPage.find_product_name(driver) for product in products: assert "Test product" not in product.text proxy_logging(proxy)
def delete_all_products(driver): """ Keyword - del all products """ ProductPage.click_choose_all_products_checkbox(driver) ProductPage.click_delete_all_products_button(driver) log.info("All products has been deleted")
def filter_products_by_name(driver, product_name): """ Keyword - filter product by name """ ProductPage.input_product_name_to_filter(driver, product_name) ProductPage.click_filter_button(driver) log.info("Products has been filtered by name:%s", product_name)
def test003(start_browser): """ Test type - positive Edit product :param start_browser: browser run """ with allure.step('Running test case'): driver, proxy = start_browser with allure.step('Authorize as admin'): authorize_as_admin(driver, login="******", password="******") with allure.step('Add new product'): add_new_product(driver, product_name="Test product", meta_tag="Test meta tag", model="Test model") with allure.step('Edit product'): filter_products_by_name(driver, product_name="Test product") ProductPage.find_and_click_edit_button(driver) ProductPage.clear_product_name_field(driver) ProductPage.input_product_name(driver, product_name="Edited test product") ProductPage.save_new_product_button_click(driver) ProductPage.clear_filter_name_filed(driver) with allure.step('Check product'): filter_products_by_name(driver, product_name="Edited test product") products = ProductPage.find_product_name(driver) for product in products: assert "Edited test product" in product.text with allure.step('Delete product'): filter_products_by_name(driver, product_name="Edited test product") delete_all_products(driver) ProductPage.accept_product_delete(driver) proxy_logging(proxy)
def delete_images_from_opencart(driver, file_names): """ Keyword - delete all images from opencart """ MainPage.open_product_catalog(driver) MainPage.click_product_button(driver) ProductPage.add_new_product_button_click(driver) ProductPage.click_on_image_tab(driver) ProductPage.click_on_image(driver) ProductPage.click_on_edit_image_button(driver) ProductPage.choose_remove_images_by_names(driver, file_names) ProductPage.delete_selected_images(driver) ProductPage.close_add_image_menu() log.info("Images have been deleted")
def add_new_product_with_images(driver, product_name, meta_tag, model, images_path, file_names): """ Keyword - add product with img """ MainPage.open_product_catalog(driver) MainPage.click_product_button(driver) ProductPage.add_new_product_button_click(driver) ProductPage.input_product_name(driver, product_name) ProductPage.input_meta_tag(driver, meta_tag) ProductPage.data_tab_click(driver) ProductPage.input_model(driver, model) ProductPage.click_on_image_tab(driver) ProductPage.click_on_image(driver) ProductPage.click_on_edit_image_button(driver) ProductPage.add_new_images_to_store(driver, images_path, *file_names) ProductPage.close_add_image_menu() ProductPage.add_images_to_product(driver, *file_names) log.info("Add product with img - success")
def add_new_product(driver, product_name, meta_tag, model): """ Keyword - add product """ MainPage.open_product_catalog(driver) MainPage.click_product_button(driver) ProductPage.add_new_product_button_click(driver) ProductPage.input_product_name(driver, product_name) ProductPage.input_meta_tag(driver, meta_tag) ProductPage.data_tab_click(driver) ProductPage.input_model(driver, model) ProductPage.save_new_product_button_click(driver) log.info("Product has been created")