Beispiel #1
0
class Application:
    def __init__(self, browser, base_url):
        if browser == "firefox":
            self.wd = webdriver.Firefox()
        elif browser == "chrome":
            self.wd = webdriver.Chrome()
        elif browser == "ie":
            self.wd = webdriver.Ie()
        else:
            raise ValueError("Unrecognized browser %s" % browser)
#        self.wd.implicitly_wait(5)
        self.session = SessionHelper(self)
        #       self.group = GroupHelper(self)
        self.base_url = base_url
        self.catalog_page = CatalogPage(self.wd)

    def open_home_page(self):
        wd = self.wd
        wd.get(self.base_url)

    def destroy(self):
        self.wd.quit()

    def is_valid(self):
        try:
            self.wd.current_url
            return True
        except:
            return False

    def add_new_product(self, new_product):
        self.catalog_page.open()
        self.catalog_page.add_new_product_form()
        self.catalog_page.status_enabled()
        self.catalog_page.product_name_input.send_keys("name",
                                                       new_product.name)
        self.catalog_page.product_code_input.send_keys("code",
                                                       new_product.code)
        category = self.catalog_page.select_random_category()
        category.click()
        self.catalog_page.select_gender()
        self.catalog_page.quantity_input.send_keys("quantity",
                                                   new_product.quantity)
        self.catalog_page.date_valid_from_input.send_keys(
            "date_valid_from", new_product.date_valid_from)
        self.catalog_page.date_valid_to_input.send_keys(
            "date_valid_to", new_product.date_valid_to)
        self.catalog_page.save_general_info()
Beispiel #2
0
class Application:
    def __init__(self):
        self.driver = webdriver.Chrome()  #Chrome  Ie  Firefox
        self.catalog_page = CatalogPage(self.driver)
        self.general_page = GenaralPage(self.driver)
        self.info_page = InfoPage(self.driver)
        self.prices_page = PricesPage(self.driver)
        self.login = Login(self.driver)
        self.product = Product(self)
        self.supporting = Supporting(self.driver)

    def quit(self):
        self.driver.quit()

    def login_admin(self):
        if self.login.open().is_on_this_page():
            self.login.authorization()
            return self.catalog_page.open()

    def catalog_page_button(self):
        self.catalog_page.new_product_button()

    def fill_general_page(self, product):
        self.general_page.input_name_product.send_keys(product.product_name)
        self.general_page.input_code_product.send_keys(product.product_code)
        self.general_page.input_date_from.send_keys(product.date_from)
        self.general_page.input_date_to.send_keys(product.date_to)
        self.general_page.select_quantity_unit()
        self.general_page.select_delivery_status()
        self.general_page.select_sold_out_status()
        self.general_page.upload_image()
        self.general_page.input_radio_but.click()
        self.general_page.input_check_b()
        self.general_page.input_check_b2()

    def fill_info_page(self, product):
        self.catalog_page.click_info_part.click()
        self.info_page.input_head_title.send_keys(product.head_title)
        self.info_page.input_keywords.send_keys(product.keywords)
        self.info_page.input_short_descr.send_keys(product.short_desc)
        self.info_page.input_meta_descr.send_keys(product.meta_desc)
        self.info_page.select_manufacturer_id()
        self.info_page.put_full_descr.send_keys(product.full_desc)

    def fill_prices_page(self, product):
        self.catalog_page.click_prices_part.click()
        self.prices_page.input_purchase_price.clear()
        self.prices_page.input_purchase_price.send_keys(product.purchase_price)
        self.prices_page.input_USD.send_keys(product.prices_USD)
        self.prices_page.input_EUR.send_keys(product.prices_EUR)
        self.prices_page.select_purchase_currency()
        self.catalog_page.click_save_button.click()
Beispiel #3
0
def catalog_page(request, driver, url):
    catalog_page = CatalogPage(driver, url, request.param)
    catalog_page.open()
    return catalog_page