How to Exit from For loop in Robot framework using seleniumlibrary

Viewed 16

Question:Here loop is not stoping after the requirement meet it is trying to start loop again from else statement

Fetching Quarterly reports [Arguments] ${noofloop} ${mainloop} ${DownloadFilepath} ${ReportFilename} ${ReportFilename1} ${ReportFilepath} ${Backupfolder} ${set_year} ${today's_date} = Get Current Date result_format=%m/%d/%Y FOR ${i} IN RANGE 1 10 ${noofloop} Evaluate ${noofloop}+1 ${to_date} Run keyword If '${noofloop}'=='1' January Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='2' February Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='3' March Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='4' April Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='5' May Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='6' June Month ${noofloop} ${mainloop} ${today's_date} ${set_year} ... ELSE IF '${noofloop}'=='7' July Month ${noofloop} ${mainloop} ${today's_date} ${set_year}

    ...    ELSE IF    '${noofloop}'=='8'    August Month    ${noofloop}    ${mainloop}    ${today's_date}    ${set_year}
    ...    ELSE IF    '${noofloop}'=='9'    September Month    ${noofloop}    ${mainloop}    ${today's_date}    ${set_year}
    Input Text    ${to_date_field}    ${to_date}
    Sleep    10s
    Selenium2Library.Click Element    //*[@id="encounterLink11"]
    sleep    5s
    Selenium2Library.Click Element    //*[@id="encounterLink11"]
    sleep    5s
    Wait Until Element Is Visible    ${filter_button}
    Selenium2Library.Click Element    ${filter_button}
    sleep    10s
    ${no_records_found}    Run Keyword And Return Status    Element Should Be Visible    //div[@id='divNoRecordsFound']
    ${no_records_found}    Run keyword If    '${no_records_found}'== 'True'    Fetching Quarterly reports    ${noofloop}    ${mainloop}    ${DownloadFilepath}    ${ReportFilename}    ${ReportFilename1}    ${ReportFilepath}    ${Backupfolder}    ${set_year}
    ...    ELSE    Click Element    //*[@id="open"]/div[2]/div/div[1]/button[2]
    sleep    5s
    Wait Until Element Is Visible    ${Excel_option}
    Selenium2Library.Click Element    ${Excel_option}
    Sleep    5s
    Wait Until Element Is Visible    //*[@id="open"]/div[2]/div/div[1]/button[2]
    Selenium2Library.Click Element    //*[@id="open"]/div[2]/div/div[1]/button[2]
    sleep    2s
    Exit For Loop If    '${noofloop}' == '9'
END
0 Answers
Related