Exemple #1
0
class Application:
    def __init__(self):
        options = webdriver.ChromeOptions()
        options.add_argument("--start-maximized")
        self.driver = webdriver.Chrome(chrome_options=options)
        self.driver.implicitly_wait(10)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.add_to_cart_page = AddToCartPage(self.driver)
        self.main_page = MainPage(self.driver)
        self.select_product_page = SelectProductPage(self.driver)
        self.shopping_page = ShoppingPage(self.driver)
        self.add_to_user_page = AddToUserPage(self.driver)
        self.check_price_page = CheckPricePage(self.driver)
        self.check_price_yd_page = CheckPriceYDPage(self.driver)
        self.create_new_product_page = CreateNewProductPage(self.driver)
        self.add_new_product_page = AddNewProductPage(self.driver)
        self.add_new_products_in_basket_page = AddNewProductsInBasketPage(
            self.driver)
        self.check_true_page = CheckTruePage(self.driver)
        self.login_page = LoginPage(self.driver)
        self.country_zone_page = CountryZone(self.driver)

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

    def login(self, username, password):
        self.admin_panel_login_page.open()
        self.admin_panel_login_page.enter_username(username)
        self.admin_panel_login_page.enter_password(password)
        self.admin_panel_login_page.submit_login()
class Application:

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)

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

    def register_new_customer(self, customer):
        self.registration_page.open()
        self.registration_page.firstname_input.send_keys(customer.firstname)
        self.registration_page.lastname_input.send_keys(customer.lastname)
        self.registration_page.address1_input.send_keys(customer.address)
        self.registration_page.postcode_input.send_keys(customer.postcode)
        self.registration_page.city_input.send_keys(customer.city)
        self.registration_page.select_country(customer.country)
        self.registration_page.select_zone(customer.zone)
        self.registration_page.email_input.send_keys(customer.email)
        self.registration_page.phone_input.send_keys(customer.phone)
        self.registration_page.password_input.send_keys(customer.password)
        self.registration_page.confirmed_password_input.send_keys(customer.password)
        self.registration_page.create_account_button.click()

    def get_customer_ids(self):
        if self.admin_panel_login_page.open().is_on_this_page():
            self.admin_panel_login_page.enter_username("admin").enter_password("pass").submit_login()
        return self.customer_list_page.open().get_customer_ids()
class Application:
    def __init__(self):
        self.driver = webdriver.Chrome()
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)

        self.product_list_page = ProductListPage(self.driver)
        self.cart_page = CartPage(self.driver)

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

    def register_new_customer(self, customer):
        self.registration_page.open()
        self.registration_page.firstname_input.send_keys(customer.firstname)
        self.registration_page.lastname_input.send_keys(customer.lastname)
        self.registration_page.address1_input.send_keys(customer.address)
        self.registration_page.postcode_input.send_keys(customer.postcode)
        self.registration_page.city_input.send_keys(customer.city)
        self.registration_page.select_country(customer.country)
        self.registration_page.select_zone(customer.zone)
        self.registration_page.email_input.send_keys(customer.email)
        self.registration_page.phone_input.send_keys(customer.phone)
        self.registration_page.password_input.send_keys(customer.password)
        self.registration_page.confirmed_password_input.send_keys(
            customer.password)
        self.registration_page.create_account_button.click()

    def get_customer_ids(self):
        if self.admin_panel_login_page.open().is_on_this_page():
            self.admin_panel_login_page.enter_username("admin").enter_password(
                "admin").submit_login()
        return self.customer_list_page.open().get_customer_ids()

    def add_new_product_to_cart(self, product):
        self.product_list_page.open()
        self.product_list_page.add_in_cart(product)

    def del_product_from_cart(self, product):
        self.cart_page.open()
        self.cart_page.del_from_cart(product)

    def delete_all_from_cart(self):
        self.cart_page.open()
        self.cart_page.del_all_from_cart()

    def get_quantity_of_product_in_cart_on_prod_page(self):
        self.product_list_page.open()
        return self.product_list_page.numbers_of_prod_in_cart_on_prod_page()

    def add_random_distinct_prod(self, quantity):
        self.product_list_page.open()
        self.product_list_page.add_distinct_random_product(quantity)
Exemple #4
0
class Application:
    def __init__(self):
        options = webdriver.ChromeOptions()
        options.add_argument("--start-maximized")
        self.driver = webdriver.Chrome(chrome_options=options)
        self.driver.implicitly_wait(10)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)

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

    def login(self, username, password):
        self.admin_panel_login_page.open()
        self.admin_panel_login_page.enter_username(username)
        self.admin_panel_login_page.enter_password(password)
        self.admin_panel_login_page.submit_login()
class Application:

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(2)
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)
        self.store_main_page = StoreMainPage(self.driver)
        self.shopping_cart_page = ShoppingCartPage(self.driver)

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

    def register_new_customer(self, customer):
        self.registration_page.open()
        self.registration_page.firstname_input.send_keys(customer.firstname)
        self.registration_page.lastname_input.send_keys(customer.lastname)
        self.registration_page.address1_input.send_keys(customer.address)
        self.registration_page.postcode_input.send_keys(customer.postcode)
        self.registration_page.city_input.send_keys(customer.city)
        self.registration_page.select_country(customer.country)
        self.registration_page.select_zone(customer.zone)
        self.registration_page.email_input.send_keys(customer.email)
        self.registration_page.phone_input.send_keys(customer.phone)
        self.registration_page.password_input.send_keys(customer.password)
        self.registration_page.confirmed_password_input.send_keys(customer.password)
        self.registration_page.create_account_button.click()

    def add_items_in_shopping_cart(self, quantity=1):
        self.store_main_page.open()
        self.store_main_page.open_ducks_list.click()
        for i in range(quantity):
            random.choice(self.store_main_page.duck_list).click()
            self.store_main_page.open_duck_item.click()
            try:
                self.store_main_page.select_size("Medium")
            except:
                pass
            finally:
                self.store_main_page.add_duck_in_shopping_cart.click()
                self.store_main_page.wait_add_item_in_cart(i)

    def quantity_item_in_shopping_cart_on_main_page(self):
        return self.store_main_page.quantity_item_in_cart

    def remove_all_items_in_shopping_cart(self):
        self.shopping_cart_page.open()
        items = self.shopping_cart_page.item_list
        for i in range(len(items)):
            i_price = self.shopping_cart_page.item_price.text
            subtotal_price = self.shopping_cart_page.subtotal_price_of_all_items.text
            self.shopping_cart_page.remove_item.click()
            if i != len(items) - 1:
                self.shopping_cart_page.change_subtotal_price(subtotal_price, i_price)
            else:
                break

    def text_when_shopping_cart_list_is_empty(self):
        return self.shopping_cart_page.text_when_list_is_empty

    def get_customer_ids(self):
        if self.admin_panel_login_page.open().is_on_this_page():
            self.admin_panel_login_page.enter_username("admin").enter_password("admin").submit_login()
        return self.customer_list_page.open().get_customer_ids()
Exemple #6
0
class Application:

    def __init__(self):
        self.driver = webdriver.Chrome()
        self.registration_page = RegistrationPage(self.driver)
        self.admin_panel_login_page = AdminPanelLoginPage(self.driver)
        self.admin_panel_main_page = AdminPanelMainPage(self.driver)
        self.app_main_page = AppMainPage(self.driver)
        self.customer_list_page = CustomerListPage(self.driver)
        self.admin_countries_page = AdminCountriesPage(self.driver)
        self.admin_geo_zones_page = AdminGeoZonesPage(self.driver)
        self.admin_catalog_page = AdminCatalogPage(self.driver)

    # Admin part

    def login_to_admin(self):
        if self.admin_panel_login_page.open().is_on_this_page():
            self.admin_panel_login_page.enter_username("admin").enter_password("admin").submit_login()
        return self

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

    def register_new_customer(self, customer):
        self.registration_page.open()
        self.registration_page.firstname_input.send_keys(customer.firstname)
        self.registration_page.lastname_input.send_keys(customer.lastname)
        self.registration_page.address1_input.send_keys(customer.address)
        self.registration_page.postcode_input.send_keys(customer.postcode)
        self.registration_page.city_input.send_keys(customer.city)
        self.registration_page.select_country(customer.country)
        self.registration_page.select_zone(customer.zone)
        self.registration_page.email_input.send_keys(customer.email)
        self.registration_page.phone_input.send_keys(customer.phone)
        self.registration_page.password_input.send_keys(customer.password)
        self.registration_page.confirmed_password_input.send_keys(customer.password)
        self.registration_page.create_account_button.click()

    def get_customer_ids(self):
        self.login_to_admin()
        return self.customer_list_page.open().get_customer_ids()

    def check_admin_sections_headers(self):
        admin_sections_count = self.admin_panel_main_page.open().admin_sections_count
        self.driver.refresh()
        for x in range(admin_sections_count):
            self.admin_panel_main_page.open_section_by_index(x)
            assert self.admin_panel_main_page.section_header
            sub_sections_count = self.admin_panel_main_page.sub_sections_count(x)
            if sub_sections_count > 2:
                for y in range(2, sub_sections_count):
                    self.admin_panel_main_page.open_subsection_by_index(x, y)
                    assert self.admin_panel_main_page.section_header
        return True

    # Application part

    def open_application(self):
        return self.app_main_page.open()

    def return_max_stickers_number(self):
        counter = 0
        products_count = len(self.app_main_page.products)
        for product in range(products_count):
            if self.app_main_page.stickers_count(product) > counter:
                counter = self.app_main_page.stickers_count(product)
        return counter

    def register_new_user(self, customer):
        self.app_main_page.open()
        self.app_main_page.add_user_link_click()
        self.app_main_page.first_name_input.send_keys(customer.firstname)
        self.app_main_page.last_name_input.send_keys(customer.lastname)
        self.app_main_page.address_input.send_keys(customer.address)
        self.app_main_page.postcode_input.send_keys(customer.postcode)
        self.app_main_page.city_input.send_keys(customer.city)
        self.app_main_page.country_input.send_keys(customer.country)
        self.app_main_page.email_input.send_keys(customer.email)
        self.app_main_page.phone_input.send_keys(customer.phone)
        self.app_main_page.password_input.send_keys(customer.password)
        self.app_main_page.confirm_password_input.send_keys(customer.password)
        self.app_main_page.create_account_button_click()