Пример #1
0
def form_check_state_of_element(context: Context, actor_alias: str,
                                element: str, state: str):
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "check_state_of_form_element")
    page.check_state_of_form_element(context.driver, element, state)
    logging.debug(f"{actor_alias} saw {element} in expected {state} state on "
                  f"{context.driver.current_url}")
Пример #2
0
def generic_should_see_prepopulated_fields(context: Context, actor_alias: str,
                                           table: Table):
    table.require_columns(["form", "fields"])
    expected_form_fields = {
        row.get("form"):
        [field.strip() for field in row.get("fields").split(",") if field]
        for row in table
    }
    error = f"Expected to check at least 1 list of form fields but got 0"
    assert expected_form_fields, error

    actor = get_actor(context, actor_alias)
    page = get_last_visited_page(context, actor_alias)

    field_values_to_check = {}
    for form_name, fields in expected_form_fields.items():
        form_page_object = get_page_object(form_name)
        form_full_page_name = get_full_page_name(form_page_object)
        submitted_form_data = actor.forms_data[form_full_page_name]
        for field in fields:
            field_values_to_check[field] = submitted_form_data[field]

    logging.debug(
        f"Will check if form on '{get_full_page_name(page)}' is populated with "
        f"following values: {field_values_to_check}")
    has_action(page, "check_if_populated")
    page.check_if_populated(context.driver, field_values_to_check)
Пример #3
0
def generic_should_be_able_to_print(context: Context, actor_alias: str):
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_be_able_to_print")
    take_screenshot(context.driver, "should_be_able_to_print")
    page.should_be_able_to_print(context.driver)
    logging.debug(
        f"{actor_alias} is able to print out contents of: {context.driver.current_url}"
    )
Пример #4
0
def soo_contact_form_should_be_prepopulated(context: Context,
                                            actor_alias: str):
    actor = get_actor(context, actor_alias)
    page = get_last_visited_page(context, actor_alias)

    form_po = profile.enrol_enter_your_business_details_step_2
    form_data_key = f"{form_po.SERVICE} - {form_po.NAME} - {form_po.TYPE}"
    form_data = actor.forms_data[form_data_key]

    has_action(page, "check_if_populated")
    page.check_if_populated(context.driver, form_data)
Пример #5
0
def domestic_search_finder_should_see_page_number(context: Context,
                                                  actor_alias: str,
                                                  page_num: int):
    should_be_on_page(
        context,
        actor_alias,
        f"{domestic.search_results.SERVICE} - {domestic.search_results.NAME}",
    )
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_page_number")
    page.should_see_page_number(context.driver, page_num)
Пример #6
0
def generic_should_see_expected_page_content(context: Context,
                                             actor_alias: str,
                                             expected_page_name: str):
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_content_for")
    page.should_see_content_for(context.driver, expected_page_name)
    logging.debug(
        "%s found content specific to %s on %s",
        actor_alias,
        expected_page_name,
        context.driver.current_url,
    )
Пример #7
0
def erp_should_see_number_of_product_categories_to_expand(
        context: Context, actor_alias: str, comparison_description: str):
    comparison_details = get_comparison_details(comparison_description)

    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_number_of_product_categories_to_expand")
    take_screenshot(context.driver,
                    "should_see_number_of_product_categories_to_expand")
    check_for_errors(context.driver.page_source, context.driver.current_url)
    page.should_see_number_of_product_categories_to_expand(
        context.driver, comparison_details)
    logging.debug(
        f"{actor_alias} saw: {comparison_description} product categories(s) to expand"
    )
Пример #8
0
def should_not_see_sections(context: Context,
                            actor_alias: str,
                            sections_table: Table = None):
    sections = [row[0] for row in sections_table]
    logging.debug(f"sections {sections}")
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_not_see_section")
    for section in sections:
        page.should_not_see_section(context.driver, section)
        logging.debug(
            "As expected %s cannot see '%s' section on %s page",
            actor_alias,
            section,
            page.NAME,
        )
Пример #9
0
def should_see_sections(
    context: Context,
    actor_alias: str,
    sections_table: Table = None,
    *,
    sections_list: list = None,
):
    sections = sections_list or [row[0] for row in sections_table]
    logging.debug(
        "%s will look for following sections: '%s' on %s",
        actor_alias,
        sections,
        context.driver.current_url,
    )
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_sections")
    page.should_see_sections(context.driver, sections)
Пример #10
0
def promo_video_check_watch_time(context: Context, actor_alias: str,
                                 expected_watch_time: int):
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "get_video_watch_time")
    watch_time = page.get_video_watch_time(context.driver)
    with assertion_msg(
            "%s expected to watch at least first '%d' seconds of the video but"
            " got '%d'",
            actor_alias,
            expected_watch_time,
            watch_time,
    ):
        assert watch_time >= expected_watch_time
    logging.debug(
        "%s was able to watch see at least first '%d' seconds of the"
        " promotional video",
        actor_alias,
        expected_watch_time,
    )
Пример #11
0
def marketplace_finder_should_see_marketplaces(context: Context,
                                               actor_alias: str, country: str):
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_marketplaces")
    page.should_see_marketplaces(context.driver, country)
Пример #12
0
def generic_should_see_form_choices(context: Context, actor_alias: str,
                                    option_names: Table):
    option_names = [row[0] for row in option_names]
    page = get_last_visited_page(context, actor_alias)
    has_action(page, "should_see_form_choices")
    page.should_see_form_choices(context.driver, option_names)
Пример #13
0
def language_selector_should_see_it(context: Context, actor_alias: str):
    page = get_last_visited_page(context, actor_alias)
    common_language_selector.should_see_it_on(context.driver, page=page)
    logging.debug("As expected %s can see language selector", actor_alias)