Exemplo n.º 1
0
def visit_page(context: Context, actor_alias: str, page_name: str):
    """Will visit specific page.

    NOTE:
    In order for the retry scheme to work properly you should have
    the webdriver' page load timeout set to value lower than the retry's
    `wait_fixed` timer, e.g `driver.set_page_load_timeout(time_to_wait=30)`
    """
    def is_special_case(page_name: str) -> bool:
        parts = page_name.split(" - ")
        return len(parts) == 3

    if not get_actor(context, actor_alias):
        add_actor(context, unauthenticated_actor(actor_alias))

    page = get_page_object(page_name)

    has_action(page, "visit")

    if is_special_case(page_name) and hasattr(page, "SubURLs"):
        subpage_name = page_name.split(" - ")[1].lower()
        special_url = page.SubURLs[subpage_name]
        logging.debug(
            f"{actor_alias} will visit '{page_name}' subpage using: '{special_url}"
        )
        page.visit(context.driver, page_name=subpage_name)
    else:
        logging.debug(
            f"{actor_alias} will visit '{page_name}' page using: '{page.URL}'")
        page.visit(context.driver)

    take_screenshot(context.driver, f"visit page {page_name}")
    accept_all_cookies(context.driver)
    check_for_errors(context.driver.page_source, context.driver.current_url)
    update_actor(context, actor_alias, visited_page=page)
Exemplo n.º 2
0
def profile_start_registration_as(context: Context, actor_alias: str,
                                  business_type: str):
    if not get_actor(context, actor_alias):
        add_actor(context, unauthenticated_actor(actor_alias))
    profile.enrol_select_business_type.visit(context.driver)
    second_page = profile.enrol_select_business_type.pick_radio_option_and_submit(
        context.driver, name=business_type)
    should_be_on_page(context, actor_alias,
                      f"{second_page.SERVICE} - {second_page.NAME}")
Exemplo n.º 3
0
def domestic_open_random_market(context: Context, actor_alias: str):
    if not get_actor(context, actor_alias):
        add_actor(context, unauthenticated_actor(actor_alias))
    driver = context.driver
    domestic.markets_listing.visit(driver)
    take_screenshot(driver, domestic.markets_listing.NAME)
    check_for_errors(driver.page_source, driver.current_url)
    market_name = domestic.markets_listing.open_random_marketplace(driver)
    domestic.market_country_guide.should_be_here(driver)
    update_actor(
        context,
        actor_alias,
        visited_page=domestic.market_country_guide,
        article_url=driver.current_url,
        visited_articles=market_name,
    )
Exemplo n.º 4
0
def domestic_open_random_advice_article(context: Context, actor_alias: str):
    if not get_actor(context, actor_alias):
        add_actor(context, unauthenticated_actor(actor_alias))
    driver = context.driver
    domestic.advice_landing.visit(driver)
    take_screenshot(driver, domestic.advice_landing.NAME)
    check_for_errors(driver.page_source, driver.current_url)
    advice_name = domestic.advice_landing.open_any_article(driver)
    article_name = domestic.advice_article_list.open_any_article(driver)
    domestic.advice_article.should_be_here(driver)
    update_actor(
        context,
        actor_alias,
        visited_page=domestic.advice_article,
        article_url=driver.current_url,
        article_category=advice_name,
        visited_articles=article_name,
    )