def test004(start_browser, address): """ Test type - positive Create new product with 3 images :param start_browser: browser run :param address: fixture with parametrized url of opencart """ driver, proxy = start_browser driver.get(address) images_names = ("image1", "image2", "image3") jpg_names = list() for name in images_names: jpg_names.append(str(name)+".jpg") with allure.step('Authorization in admin login mask'): authorize_as_admin(driver, login="******", password="******") with allure.step('Adding 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/zhukov/Documents/nokia_images/", file_names=jpg_names) with allure.step('Looking for product images by names'): ProductPage.check_images_names(driver, images_names) with allure.step('Removing images'): delete_images_from_opencart(driver, file_names=jpg_names) with allure.step('Removing product'): MainPage.open_product_catalog(driver) MainPage.click_product_button(driver) filter_products_by_name(driver, product_name="Test product") delete_all_products(driver)
def test001(start_browser, address): """ Test type - positive Add new product :param start_browser: browser run :param address: fixture with parametrized url of opencart """ driver, proxy = start_browser driver.get(address) with allure.step('Authorization in admin login mask'): authorize_as_admin(driver, login="******", password="******") with allure.step('Adding new product'): add_new_product(driver, product_name="Test product", meta_tag="Test meta tag", model="Test model") filter_products_by_name(driver, product_name="Test product") with allure.step('Looking for created product'): products = ProductPage.find_product_name(driver) for product in products: logging.debug(product) assert "Test product" in product.text with allure.step('Removing product'): delete_all_products(driver) ProductPage.accept_product_delete(driver)
def test002(start_browser, address): """ Test type - positive Delete product :param start_browser: browser run :param address: fixture with parametrized url of opencart """ driver, proxy = start_browser driver.get(address) with allure.step('Authorization in admin login mask'): authorize_as_admin(driver, login="******", password="******") with allure.step('Adding new product'): add_new_product(driver, product_name="Test product", meta_tag="Test meta tag", model="Test model") with allure.step('Removing product'): filter_products_by_name(driver, product_name="Test product") delete_all_products(driver) ProductPage.accept_product_delete(driver) with allure.step('Looking for removed product'): 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_logs_write(proxy) web_logging(driver, log_file='web_log.log')
def delete_images_from_opencart(driver, file_names): 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()
def add_new_product_with_images(driver, product_name, meta_tag, model, images_path, file_names): 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) logging.info("Product has been created")
def delete_all_products(driver): ProductPage.click_choose_all_products_checkbox(driver) ProductPage.click_delete_all_products_button(driver) logging.info("All products has been deleted")
def filter_products_by_name(driver, product_name): ProductPage.input_product_name_to_filter(driver, product_name) ProductPage.click_filter_button(driver) logging.info("Products has been filtered by name:{}".format(product_name))
def add_new_product(driver, product_name, meta_tag, model): 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) logging.info("Product has been created")