playtender_plan.robot 5.74 KB
*** Settings ***

Resource                                                        playtender_common.robot

*** Keywords ***

open new plan form
    [Documentation]                                             відкриття сторінки створення плану

    open page and wait element by locator                       ${broker_baseurl}/plan/create  ${plan_form_locator}

open plan page by uaid
    [Arguments]                                                 ${uaid}
    [Documentation]                                             відкриває сторінку з планом

    open page and wait element by locator                       ${broker_baseurl}/plan/${uaid}  ${plan_view_checker_element_locator}

open plan search form
    [Documentation]                                             відкриває сторінку з пошуком планів

    open page and wait element by locator                       ${broker_baseurl}/plans  ${plan_search_form_locator}

fill plan form
    [Arguments]                                                 ${data}
    [Documentation]                                             заповнення форми з масива даних

    # check buyers
    ${buyers_count} =                                           get length  ${data['buyers']}
    run keyword if                                              ${buyers_count} != 1  fail  Buyer must be one

    # hidden inputs
    ${budget_id} =                                              get from dictionary by keys  ${data}  budget  id
    run keyword if condition is not none                        ${budget_id}  input text to hidden input  ${plan_form_budget_id_input_locator}  ${budget_id}
    ${project_id} =                                             get from dictionary by keys  ${data}  budget  project  id
    run keyword if condition is not none                        ${project_id}  input text to hidden input  ${plan_form_project_id_input_locator}  ${project_id}
    ${project_name} =                                           get from dictionary by keys  ${data}  budget  project  name
    run keyword if condition is not none                        ${project_name}  input text to hidden input  ${plan_form_project_name_input_locator}  ${project_name}

    # general info
    open popup by btn locator                                   ${plan_form_general_panel_edit_btn_locator}
    ${procurement_method_type} =                                get from dictionary by keys  ${data}  tender  procurementMethodType
    run keyword if condition is not none                        ${procurement_method_type}  select from visible list by value  ${plan_form_procurement_method_type_input_locator}  ${procurement_method_type}
    ${budget_description} =                                     get from dictionary by keys  ${data}  budget  description
    run keyword if condition is not none                        ${budget_description}  input text to visible input  ${plan_form_title_input_locator}  ${budget_description}
    ${tender_start_date} =                                      get from dictionary by keys  ${data}  tender  tenderPeriod  startDate
    run keyword if condition is not none                        ${tender_start_date}  select from visible list by year of date  ${plan_form_year_input_locator}  ${tender_start_date}
    run keyword if condition is not none                        ${tender_start_date}  input month.year of date to visible input  ${plan_form_tender_start_date_input_locator}  ${tender_start_date}
    ${amount} =                                                 get from dictionary by keys  ${data}  budget  amount
    run keyword if condition is not none                        ${amount}  input number to visible input  ${plan_form_value_amount_input_locator}  ${amount}
    ${currency} =                                               get from dictionary by keys  ${data}  budget  currency
    run keyword if condition is not none                        ${currency}  select from visible list by value  ${plan_form_value_currency_input_locator}  ${currency}
    ${classification} =                                         get from dictionary by keys  ${data}  classification
    run keyword if condition is not none                        ${classification}  select classification by code attributes  ${plan_form_classification_edit_btn_locator}  ${classification}
    ${additional_classifications} =                             get from dictionary by keys  ${data}  additionalClassifications
    run keyword if condition is not none                        ${additional_classifications}  select classification by array of code attributes  ${plan_form_additional_classification_edit_btn_locator}  ${additional_classifications}  ${None}  ${kekv_schemes}
    run keyword if condition is not none                        ${additional_classifications}  select classification by array of code attributes  ${plan_form_kekv_classification_edit_btn_locator}  ${additional_classifications}  ${kekv_schemes}
    submit current visible popup

    # items
    ${items} =                                                  get from dictionary by keys  ${data}  items
    run keyword if condition is not none                        ${items}  fill plan form items  ${items}

fill plan form items
    [Arguments]                                                 ${item_attributes_array}
    [Documentation]                                             заповнення номенклатури плану

    :FOR  ${item_attributes}  IN  @{item_attributes_array}
    \  click visible element                                    ${plan_form_add_item_btn_locator}
    \  wait until popup is visible
    \  fill item form in opened popup                           ${item_attributes}
    \  submit current visible popup