robotframework-browser icon indicating copy to clipboard operation
robotframework-browser copied to clipboard

Promise To Wait For Download with custom timeout argument

Open adrian-evo opened this issue 4 years ago • 3 comments

Currently when I would like to have a custom timeout for this keyword, I would need to use the following workaround:

Suppose the default browser timeout is set globally on suite setup:

Suite Setup
    New Context          acceptDownloads=True
    Set Browser Timeout    ${DEFAULT_WAIT}
    ...

Then on specific test case, I would need a custom timeout, expecting a longer than normal download timeout:

Test Case
    New Page             ${LOGIN_URL}
    Set Browser Timeout    ${LONG_WAIT}
    ${dl_promise}        Promise To Wait For Download    /path/to/download/folder
    Click                \#file_download

    # Restore default timeout if download fails
    ${status}    ${file_obj}    Run Keyword And Ignore Error    Wait For    ${dl_promise}
    Set Browser Timeout    ${DEFAULT_WAIT}
    IF    '${status}' == 'FAIL'
        Take Screenshot
        Fail    ${file_obj}
    END

    File Should Exist    ${file_obj}[saveAs]
    Should Be True       ${file_obj.suggestedFilename}

Considering this, it would be useful if Promise To Wait For Download keyword could have a default timeout argument, like e.g. Wait For Request keyword, if possible.

adrian-evo avatar Jun 23 '21 08:06 adrian-evo

@all-contributors please add @adrian-evo for ideas

aaltat avatar Jun 23 '21 08:06 aaltat

@aaltat

I've put up a pull request to add @adrian-evo! :tada:

allcontributors[bot] avatar Jun 23 '21 08:06 allcontributors[bot]

Fully agree that ability to set custom timeout for Promise To Wait For Download would be useful especially for cases when file is generated and longer waiting time is expected.

JaPyR avatar May 17 '22 14:05 JaPyR

Will be fixed/implemented with #3228

Snooz82 avatar Nov 09 '23 17:11 Snooz82