playtender_claim.robot 36.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
*** Settings ***

Resource                                                        playtender_common.robot
Resource                                                        playtender_claim_variables.robot

*** Keywords ***


Створити вимогу
    [Arguments]                                                 ${username}  ${tender_uaid}  ${type}  ${type_id}  ${claim}  ${doc_name}
    [Documentation]                                             Створити вимогу з claim в описі для тендера tender_uaid.

    open tender page by uaid                                    ${tender_uaid}
#fix cat
#    log many  ${SUITE_NAME}
    log many  ${TEST_NAME}

    submit form and check result                                ${bid_form_refresh_btn_locator}  ${bid_form_refresh_success_msg}  ${tender_created_checker_element_locator}  ${true}
    click visible element                                       ${claim_page_open_btn_locator}
    capture page screenshot
    wait until page contains element with reloading             ${claim_form_open_btn_locator}
    open popup by btn locator                                   ${claim_form_open_btn_locator}
    capture page screenshot
    input text to exist visible input                           ${claim_form_complaintform_title_input_locator}  ${claim.data.title}
    capture page screenshot
    input text to exist visible input                           ${claim_form_complaintform_description_input_locator}  ${claim.data.description}
    capture page screenshot
    Run Keyword And Ignore Error                                Run Keyword If  '${type}' == 'tender'  Select From List By Label  ${claim_form_complaintform_related_of_input_locator}  Закупівля
    capture page screenshot
    Run Keyword And Ignore Error                                Run Keyword If  '${type}' == 'lot'  Select From List By Label  ${claim_form_complaintform_related_of_input_locator}  Лот
    capture page screenshot
    Run Keyword And Ignore Error                                Run Keyword If  '${type}' == 'lot'  Click Element  ${claim_form_complaintform_related_lot_input_locator}
    ${claim_form_complaintform_related_lot_select_locator} =    Run Keyword If  '${type}' == 'lot'   replace string  ${claim_form_complaintform_related_lot_input_locator_tpl}  %type_id%  ${type_id}
    Run Keyword And Ignore Error                                Run Keyword If  '${type}' == 'lot'  Click Element  ${claim_form_complaintform_related_lot_select_locator}
    capture page screenshot
    Run Keyword And Ignore Error                                Select From List By Label  ${claim_form_complaintform_complaintform_type_input_locator}  Вимога
    Run Keyword And Ignore Error                                Run Keyword If  '${type}' == 'winner_complaint' or '${claim.data.type}' == 'complaint'   Select From List By Label  ${claim_form_complaintform_complaintform_type_input_locator}  Скарга

    capture page screenshot
###    Run Keyword If  '${doc_name}' != 'null'                     click visible element   ${claim_form_complaintform_document_btn_locator}
    capture page screenshot
#    ${file_path}  ${file_name}  ${file_content} =               create_fake_doc
    choose file                                                 ${add_file_to_form_locator}  ${CURDIR}/Key-6.dat
    Run Keyword If  '${doc_name}' != 'null'                     choose file   ${add_file_to_form_locator}  ${doc_name}
    capture page screenshot
    wait until page does not contain element                    ${popup_dynamic_form_loading_element_locator}
    Run Keyword If  '${doc_name}' != 'null'                     wait until page does not contain element   ${popup_dynamic_form_loading_element_locator}
    capture page screenshot
#    Run Keyword If  '${doc_name}' != 'null'                     submit current visible popup
    submit form and check result                                ${claim_form_complaintform_submit_btn_locator}  ${claim_form_submit_success_msg}  ${tender_created_checker_element_locator}  ${true}
#    Функция ожидания claim_uaid_text_locator соответствующей вимоги
#    click visible element                                       ${claim_form_open_btn_locator}
    reload page
    wait until page does not contain element with reloading     ${claim_sync_element_locator}  60
    wait until page contains element with reloading             ${claim_uaid_text_locator}
    ${return_value}=                                            get text  ${claim_uaid_text_locator}
    ${return_value}=                                            Convert To String  ${return_value}

#    ${tender_с}=  getTenderDataByTenderComplaintsUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
#    ${tender_с}=  op_robot_tests.tests_files.service_keywords.Munchify  ${tender_с}

#    Log  ${tender_с}
    # bof - fix #
    ${complaint} =                                              Run Keyword If  "на скасування" in "${TEST_NAME}"   getLastCancellationComplaintDataByTenderUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
    ...                                                         ELSE IF  "переможця" in "${TEST_NAME}"   getLastAwardComplaintDataByTenderUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
    ...                                                         ELSE IF  "кваліфікацію" in "${TEST_NAME}"  or "прекваліфікацію" in "${TEST_NAME}"   getLastQualificationComplaintDataByTenderUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
    ...                                                         ELSE  getLastComplaintDataByTenderUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
##    ${complaint}=  getLastComplaintDataByTenderUaId  ${API_HOST_URL}/api/${API_VERSION}  ${tender_uaid}
#    Log  ${complaint}  getLastAwardComplaintDataByTenderUaId
# getLastCancellationComplaintDataByTenderUaId
#    ${complaint}=  json_load  ${complaint}
#    Log  ${complaint}
    ${complaint}=  op_robot_tests.tests_files.service_keywords.Munchify  ${complaint}
    log dictionary  ${complaint}
##    ${complaint} =                                              playtender_service.split_complaintdata  ${complaint}
##    Log  ${complaint}
##    ${complaint}=                                               munch_dict  arg=${complaint}
#    Set To Dictionary  ${USERS.users['${username}']}      complaint_data=${complaint}
    Set To Dictionary  ${USERS.users['${username}']}  complaint_access_token=123
#    Log  ${USERS.users['playtender_Provider'].complaint_data['complaintID']}
#    Log  ${USERS.users['${username']}.tender_data}
    # eof - fix #

#    [return]                                                    ${return_value}
    [return]                                                    ${complaint}

Скасувати вимогу
    [Arguments]                                                 ${username}  ${tender_uaid}  ${complaintID}  ${cancellation_data}  ${award_index}
    [Documentation]                                             Перевести вимогу complaintID  для тендера tender_uaid у статус cancelled,
    ...                                                         використовуючи при цьому дані confirmation_data.

    open tender page by uaid                                    ${tender_uaid}
    click visible element and wait until page contains element  ${claim_page_open_btn_locator}  ${claim_form_open_btn_locator}
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    wait until page contains element with reloading             ${claim_open_form_answer_locator}
    ${claim_form_cancel_open_btn_locator} =                     replace string  ${claim_form_cancel_open_btn_locator_tpl}  %complaint_id%  ${complaintID}
    wait until page contains element with reloading             ${claim_form_cancel_open_btn_locator}
    open popup by btn locator                                   ${claim_form_cancel_open_btn_locator}
    capture page screenshot
    input text to exist visible input                           ${claim_form_cancellation_reason_input_locator}  ${cancellation_data.data.cancellationReason}
    capture page screenshot
    submit form and check result                                ${claim_form_complaintform_submit_btn_locator}  ${claim_cancel_submit_success_msg}  ${tender_created_checker_element_locator}

get claim information
    [Arguments]                                                 ${tender_uaid}  ${complaintID}  ${field_name}  ${award_index}=${None}
    [Documentation]                                             Отримати значення поля field_name скарги/вимоги complaintID про
    ...                                                         виправлення умов закупівлі/лоту для тендера tender_uaid (скарги/вимоги про
    ...                                                         виправлення визначення переможця під номером award_index, якщо award_index != None).

    open tender page by uaid                                    ${tender_uaid}
    click visible element                                       ${claim_page_open_btn_locator}
    capture page screenshot
#    Run Keyword And Return If                                   '${TEST_NAME}' == 'Відображення статусу \'draft\' чернетки скарги'    Fail   Поле не відображаем
    Run Keyword And Return If                                   "чернетки скарги" in "${TEST_NAME}"   Fail   Поле не відображаем
    Run Keyword And Return If                                   "Відображення заголовку скарги" in "${TEST_NAME}"   Fail   Поле не відображаем
    Run Keyword And Return If                                   "Відображення опису скарги" in "${TEST_NAME}"   Fail   Поле не відображаем
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    wait until page contains element with reloading             ${claim_open_form_answer_locator}  30m
    capture page screenshot

    ${claim_wrapper_complain_id_value_locator} =                set variable  ${claim_open_form_answer_locator}
#    ${claim_wrapper_complaint_id_value_locator} =               replace string  ${claim_wrapper_complain_id_value_locator_tpl}  %complain_id%  ${complaintID}
    ${claim_description_value_locator} =                        Run Keyword If  'description' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_description_value_locator}
    ${claim_title_value_locator} =                              Run Keyword If  'title' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_title_value_locator}
    ${claim_complain_id_value_locator} =                        Run Keyword If  'complaintID' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_complain_id_value_locator}
    ${claim_status_value_locator} =                             Run Keyword If  'status' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_status_value_locator}
    ${claim_resolution_type_value_locator} =                    Run Keyword If  'resolutionType' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_resolution_type_value_locator}
    ${claim_resolution_value_locator} =                         Run Keyword If  'resolution' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_resolution_value_locator}
    ${claim_satisfied_value_locator} =                          Run Keyword If  'satisfied' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_satisfied_value_locator}
    ${claim_related_lot_value_locator} =                        Run Keyword If  'relatedLot' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_related_lot_value_locator}
    ${claim_cancellation_reason_value_locator} =                Run Keyword If  'cancellationReason' == '${field_name}'   set variable  ${claim_wrapper_complain_id_value_locator} ${claim_cancellation_reason_value_locator}

    Run Keyword If                                              "${TEST_NAME}" == "Можливість відповісти на вимогу про виправлення умов закупівлі"    Wait Until Keyword Succeeds  420 s  15 s  Wait For Answered   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "${TEST_NAME}" == "Можливість відповісти на вимогу про виправлення умов лоту"    Wait Until Keyword Succeeds  420 s  15 s  Wait For Answered   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'answered'" in "${TEST_NAME}"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Answered   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "${TEST_NAME}" == "Відображення задоволення вимоги"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Satisfied   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "${TEST_NAME}" == "Відображення незадоволення вимоги"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Satisfied   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'resolved'" in "${TEST_NAME}"     Wait Until Keyword Succeeds  300 s  15 s  Wait For Resolved   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'cancelled'" in "${TEST_NAME}"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Cancelled   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'ignored'" in "${TEST_NAME}"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Ignored   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'stopping'" in "${TEST_NAME}"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Stopping   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword If                                              "Відображення статусу 'pending'" in "${TEST_NAME}"    Wait Until Keyword Succeeds  300 s  15 s  Wait For Pending   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword And Ignore Error                                Run Keyword If    "Відображення кінцевих статусів двох останніх вимог" in "${TEST_NAME}"    Wait Until Keyword Succeeds  30 s  5 s  Wait For Invalid   ${complaintID}  ${claim_wrapper_complain_id_value_locator}
    Run Keyword And Ignore Error                                Run Keyword If    "Відображення кінцевих статусів двох останніх вимог" in "${TEST_NAME}"    Wait Until Keyword Succeeds  30 s  5 s  Wait For Declined   ${complaintID}  ${claim_wrapper_complain_id_value_locator}

    Run Keyword And Return If                                   'description' == '${field_name}'   get value by locator on opened page  ${claim_description_value_locator}
    Run Keyword And Return If                                   'complaintID' == '${field_name}'   get value by locator on opened page  ${claim_complain_id_value_locator}
    Run Keyword And Return If                                   'title' == '${field_name}'   get value by locator on opened page  ${claim_title_value_locator}
    Run Keyword And Return If                                   'status' == '${field_name}'   get value by locator on opened page  ${claim_status_value_locator}
    Run Keyword And Return If                                   'resolutionType' == '${field_name}'   get value by locator on opened page  ${claim_resolution_type_value_locator}
    Run Keyword And Return If                                   'resolution' == '${field_name}'   get value by locator on opened page  ${claim_resolution_value_locator}
    Run Keyword And Return If                                   'satisfied' == '${field_name}'   Отримати інформацію із скарги satisfied  ${claim_satisfied_value_locator}
    Run Keyword And Return If                                   'relatedLot' == '${field_name}'   get value by locator on opened page  ${claim_related_lot_value_locator}
    Run Keyword And Return If                                   'cancellationReason' == '${field_name}'   get value by locator on opened page  ${claim_cancellation_reason_value_locator}

Отримати інформацію із документа скарги title
    [Arguments]                                                 ${complaintID}  ${doc_id}
    [Documentation]                                             Отримати значення поля title з документу з doc_id в описі для скарги для тендера.

    click visible element                                       ${claim_page_open_btn_locator}
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    Run Keyword And Return If                                   "Відображення заголовку документації скарги" in "${TEST_NAME}"   Fail   Поле не відображаем
    wait until page contains element with reloading             ${claim_open_form_answer_locator}
    ${claim_file_name_input_locator} =                          replace string  ${claim_file_name_input_locator_tpl}  %complain_id%  ${complaintID}
#    wait until page contains element with reloading             ${claim_file_name_input_locator}

    ${return_value} =                                           get text  ${claim_file_name_input_locator}
    [return]                                                    ${return_value}

get document complaint
    [Arguments]                                                 ${complaintID}  ${doc_id}
    [Documentation]                                             Завантажити файл doc_id до скарги complaintID для тендера tender_uaid
    ...                                                         в директорію ${OUTPUT_DIR} для перевірки вмісту цього файлу.

    ${claim_file_name_input_locator} =                          replace string  ${claim_file_name_input_locator_tpl}  %complain_id%  ${complaintID}
    wait until page contains element with reloading             ${claim_file_name_input_locator}
    ${claim_file_link_input_locator} =                          replace string  ${claim_file_link_input_locator_tpl}  %complain_id%  ${complaintID}
    ${claim_file_name_input_locator} =                          replace string  ${claim_file_name_input_locator_tpl}  %complain_id%  ${complaintID}
    wait until page contains element with reloading             ${tender_new_doc_locator}

    ${file_link} =                                              Execute Javascript  ${claim_file_link_input_locator}
    ${file_name} =                                              get text  ${claim_file_name_input_locator}
    download_file  ${file_link}  ${file_name}  ${OUTPUT_DIR}
    [return]                                                    ${file_name}


Підтвердити вирішення вимоги
    [Arguments]                                                 ${username}  ${tender_uaid}  ${type}  ${type_id}  ${complaintID}  ${data}  ${award_index}
    [Documentation]                                             Підтвердити вирішення вимоги

    open tender page by uaid                                    ${tender_uaid}
    click visible element                                       ${claim_page_open_btn_locator}
    click visible element and wait until page contains element  ${claim_page_open_btn_locator}  ${claim_form_open_btn_locator}
    ${claim_form_resolved_input_locator} =                      replace string  ${claim_form_resolved_input_locator_tpl}  %complaint_id%  ${complaintID}
    open popup by btn locator                                   ${claim_form_resolved_input_locator}
    ${value} =                                                  Set Variable If  '${data.data.satisfied}'  Задоволен  Не задоволен
    run keyword and ignore error                                select from visible list by label  ${claim_form_satisfied_input_locator}  ${value}
    capture page screenshot
    submit form and check result                                ${claim_form_complaintform_submit_btn_locator}  ${claim_form_satisfied_submit_success_msg}  ${None}


Відповісти на вимогу
    [Arguments]                                                 ${username}  ${tender_uaid}  ${complaintID}  ${answer_data}  ${award_index}
    [Documentation]                                             Відповісти на вимогу complaintID
    ...                                                         для тендера tender_uaid, використовуючи при цьому дані answer_data.

    open tender page by uaid                                    ${tender_uaid}
    click visible element                                       ${claim_page_open_btn_locator}
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    wait until page contains element with reloading             ${claim_open_form_answer_locator}
    ${claim_form_open_form_answer_btn_locator} =                replace string  ${claim_form_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    wait until page contains element with reloading             ${claim_form_open_form_answer_btn_locator}
    open popup by btn locator                                   ${claim_form_open_form_answer_btn_locator}
    input text to exist visible input                           ${claim_form_answer_resolution_value_locator}  ${answer_data.data.resolution}
    Run Keyword If                                              '${answer_data.data.resolutionType}' == 'resolved'  select from list by value  ${claim_form_answer_resolution_type_value_locator}  resolved
    Run Keyword If                                              '${answer_data.data.resolutionType}' == 'declined'  select from list by value  ${claim_form_answer_resolution_type_value_locator}  declined
    Run Keyword If                                              '${answer_data.data.resolutionType}' == 'invalid'  select from list by value  ${claim_form_answer_resolution_type_value_locator}  invalid
    Run Keyword And Ignore Error                                input text to exist visible input  ${claim_form_answer_tenderer_action_value_locator}  ${answer_data.data.tendererAction}
    submit form and check result                                ${claim_form_answer_success_btn_locator}  ${claim_form_answer_submit_success_msg}


Wait For Answered
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  answered
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Wait For Satisfied
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_satisfied_value_locator} =                     replace string  ${claim_form_satisfied_value_locator_tpl}  %query%  Так
    ${claim_form_satisfied_value_locator_tmp} =                 set variable  ${wrapper} ${claim_form_satisfied_value_locator}
    Page Should Contain Element                                 ${claim_form_satisfied_value_locator_tmp}

Wait For Resolved
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_resolved_value_locator} =                      replace string  ${claim_form_status_locator_tpl}  %query%  resolved
    ${claim_form_resolved_value_locator_tmp} =                  set variable  ${wrapper} ${claim_form_resolved_value_locator}
    Page Should Contain Element                                 ${claim_form_resolved_value_locator_tmp}

Wait For Cancelled
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  cancelled
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Wait For Ignored
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  ignored
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Wait For Stopping
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Answered вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  stopping
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Wait For Pending
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Pending вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  pending
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Отримати інформацію із скарги satisfied
    [Arguments]                                                 ${wrapper}
    [Documentation]                                             Отримати інформацію із скарги satisfied


    ${return_value} =                                           get value by locator on opened page  ${wrapper}
    ${return_value} =                                           Run Keyword If  'Так' == '${return_value}'  Set Variable  True
    ...                                                         ELSE Set Variable  False
    ${return_value} =                                           Convert To Boolean  ${return_value}
    [return]                                                    ${return_value}

Wait For Invalid
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу Invalid вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  invalid
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}

Wait For Declined
    [Arguments]                                                 ${complaintID}  ${wrapper}
    [Documentation]                                             Очікування статусу declined вимоги complaintID
    ...                                                         для тендера tender_uaid.

    Reload Page
    ${claim_form_status_locator} =                              replace string  ${claim_form_status_locator_tpl}  %query%  declined
    ${claim_status_value_locator} =                             set variable  ${wrapper} ${claim_form_status_locator}
    Page Should Contain Element                                 ${claim_status_value_locator}


Change the status of the complaint
    [Arguments]                                                 ${username}  ${tender_uaid}  ${complaintID}  ${confirmation_data}
    [Documentation]                                             Змінює статус скарги complaintID

    open tender page by uaid                                    ${tender_uaid}
    log many  ${confirmation_data}
    capture page screenshot
    click visible element                                       ${claim_page_open_btn_locator}
    capture page screenshot
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    capture page screenshot
    wait until page contains element with reloading             ${claim_open_form_answer_locator}
    capture page screenshot
    Run Keyword If                                              '${confirmation_data.data.status}' == 'mistaken'  Run keywords
    ...                                                         Execute Javascript  $('#tender-complaint-list a[href*="/tender-complaint/complaint-cancel"]').click()
    ...  AND  capture page screenshot
#    ...  capture page screenshot
#    ...  AND                                                         wait until element is visible  ${select_complaint_submit_success_msg}  5
    ...  AND  capture page screenshot
    ...  AND  sleep  15
    ...  AND  capture page screenshot
    ...  AND                                                         submit form and check result                                ${qualification_form_submit_btn_locator}  ${select_complaint_submit_success_msg}  ${true}
    ...  AND  capture page screenshot
    ...  AND                                                         wait until alert is visible    ${select_complaint_success_btn_locator}
    ...  AND  capture page screenshot
    ...  AND                                                         close current visible alert
    ...  AND  capture page screenshot
    ${claim_form_open_form_change_status_btn_locator} =         replace string  ${claim_form_open_form_change_status_btn_locator_tpl}  %title%  ${complaintID}
    Run Keyword If                                              '${confirmation_data.data.status}' == 'resolved'  Run keywords
    ...  wait until page contains element with reloading             ${claim_form_open_form_change_status_btn_locator}
    ...  AND  capture page screenshot
    ...  AND  open popup by btn locator                                   ${claim_form_open_form_change_status_btn_locator}
    ...  AND  capture page screenshot
    ...  AND  input text to exist visible input                           ${claim_form_change_status_resolution_value_locator}  ${confirmation_data.data.tendererAction}
    ...  AND  capture page screenshot
    ...  AND  sleep  15
    ...  AND  submit form and check result                                ${claim_form_change_status_success_btn_locator}  ${claim_form_change_status_submit_success_msg}  ${true}
    capture page screenshot


complete the payment of the complaint
    [Arguments]                                                 ${username}  ${payment_data}
    [Documentation]                                             Виконати оплату скарги

#    open tender page by uaid                                    ${tender_uaid}
    capture page screenshot
    click visible element                                       ${claim_page_open_btn_locator}
    capture page screenshot
#    Execute Javascript  $('#tender-complaint-list a[href*="/testing/complaint-status-change"]').click()
    Execute Javascript  document.querySelector(".js-complaint-status-change").click()
    capture page screenshot

Upload documentation to requirement
    [Arguments]                                                 ${username}  ${tender_uaid}  ${complaintID}  ${document}
    [Documentation]                                             Завантажити документацію до вимоги

    open tender page by uaid                                    ${tender_uaid}
    capture page screenshot
    click visible element                                       ${claim_page_open_btn_locator}
    capture page screenshot
    ${claim_open_form_answer_locator} =                         replace string  ${claim_open_form_answer_btn_locator_tpl}  %title%  ${complaintID}
    capture page screenshot
    wait until page contains element with reloading             ${claim_open_form_answer_locator}
    capture page screenshot

    Execute Javascript  $('#tender-complaint-list a[href*="/tender-complaint/update"]').click()
    capture page screenshot
    wait until page contains element                            ${add_file_to_complaint_form_locator}  10s
    choose file                                                 ${add_file_to_complaint_form_locator}  ${document}
    capture page screenshot
    sleep  3
    ${doc_name} =                                               playtender_service.split_docname  ${document}
    ${add_file_to_complaint_title_locator} =                    replace string  ${add_file_to_complaint_title_locator_tpl}  %title%  ${doc_name}
    run keyword and ignore error                                wait until page does not contain element  ${add_file_to_complaint_title_locator}
    wait until element is visible                               ${add_file_to_complaint_title_locator}
#    click visible element                                       ${select_add_file_to_complaint_success_btn_locator}
    capture page screenshot
    submit form and check result                                ${select_add_file_to_complaint_success_btn_locator}  ${select_add_file_to_complaint_submit_success_msg}  ${true}