${policy_row_xpath}= Set Variable If '${repo}'=='${null}' //clr-dg-row[contains(.,'${name}')] //clr-dg-row[contains(.,'${name}') and contains(.,'${repo}')]
Run Keyword If '${trigger_type}' == 'Scheduled' Retry Element Click ${p2p_preheat_scheduled_edit_id}
Run Keyword If '${trigger_type}' == 'Scheduled' Retry Double Keywords When Error Retry Element Click ${p2p_preheat_scheduled_type_select_id} Retry Element Click ${p2p_preheat_scheduled_type_select_id}//option[contains(.,'${schedule_type}')]
Run Keyword If '${schedule_type}' == 'Custom' Retry Text Input ${p2p_preheat_scheduled_cron_input_id} ${schedule_cron}
Run Keyword If '${trigger_type}' == 'Scheduled' Retry Element Click ${p2p_preheat_scheduled_save_btn_xpath}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_add_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_add_save_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_edit_save_btn_id}
Retry Double Keywords When Error Select P2P Preheat Policy ${name} Wait Until Element Is Visible ${p2p_execution_header}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_action_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_edit_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_name_input_id}
Retry Double Keywords When Error Select P2P Preheat Policy Trigger Scheduled Retry Element Click ${p2p_preheat_scheduled_edit_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_scheduled_type_select_id} Retry Element Click ${p2p_preheat_scheduled_type_select_id}//option[contains(.,'${type}')]
Run Keyword If '${type}' == 'Custom' Retry Text Input ${p2p_preheat_scheduled_cron_input_id} ${cron}
Retry Element Click ${p2p_preheat_scheduled_save_btn_xpath}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_edit_save_btn_id} Retry Wait Until Page Not Contains Element xpath=${p2p_preheat_edit_save_btn_id}
Verify Latest Execution Result ${project_name} ${policy_name} ${contain} ${not_contain}
Execute P2P Preheat
[Arguments] ${name} ${expected_status}=Success
Retry Double Keywords When Error Select P2P Preheat Policy ${name} Wait Until Element Is Visible ${p2p_execution_header}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_action_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_execute_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_execute_btn_id} Wait Until Element Is Visible And Enabled ${p2p_preheat_confirm_execute_btn_id}
Retry Double Keywords When Error Retry Element Click ${p2p_preheat_confirm_execute_btn_id} Wait Until Element Is Visible And Enabled //clr-datagrid//div//clr-dg-row[1]//clr-dg-cell[2][contains(.,'${expected_status}')]
${rc} ${output}= Run And Return Rc And Output curl -u ${HARBOR_ADMIN}:${HARBOR_PASSWORD} -i --insecure -H "Content-Type: application/json" -X GET "https://${ip}/api/v2.0/projects/${project_name}/preheat/policies/${policy_name}/executions/${execution_id}/tasks"