2015年2月10日 星期二

RobotFramework - 如果xx元件不存在, 執行oo

${status}    ${output}    Run Keyword And Ignore Error    Page Should Contain Element    ${ELE_XPATH}
Run Keyword If    '${status}'=='FAIL'    ${KEYWORD}

(例)
如果「檔案不存在」,就 「上傳檔案」:
Upload If File NOT Exist
   [Arguments]    ${filename}
   [Documentation]    file/folder 是否存在於目前的page
   ${status}    ${output}    Run Keyword And Ignore Error    Page Should Contain Element    //*[@class="file_list"][@title="${filename}"]
   Run Keyword If    '${status}'=='FAIL'    Upload File    ${filename}


如果「資料夾不存在」,就「建立資料夾」:
Create If Folder NOT Exist
   [Arguments]    ${folder}
   ${status}    ${output}    Run Keyword And Ignore Error    Page Should Contain Element    //*[@class="file_list"][@title="${folder}"]
   Run Keyword If    '${status}'=='FAIL'    Add Folder    ${folder}


如果「專案不存在」,就「建立專案」:
Create If Project NOT Exist
   [Arguments]    ${project}
   ${status}    ${output}    Run Keyword And Ignore Error    Page Should Contain Element    //h1[@class="projectName"][text()="${project}"]
   Run Keyword If    '${status}'=='FAIL'    Add Project    ${project}



沒有留言:

張貼留言