Close browser takes a long time when i open and close an excel file

Hello, I have made an test that checks the content of a downloaded Excel file (using the robotframework-excellib library). When the test is done and closes the document and browser, it takes more then a minute:

When I rerun the test without opening and closing the Excel-file, the same closing steps are done in mere tenths of a second:

While debugging I found the part that takes up all the time (please forgive the bad code for debugging):

  •         response = stub.CloseBrowser(Request.Empty())
    

Has anyone else experienced this? If so, how did you fix it? While it isn’t a problem at this moment, it will soon be when there are 10 tests coming that all use this technique (and I hate waiting for 10+ minutes for nothing :smiley:)

This is the part of the test that interacts with the Excel file:

  1. Check excel export

  2. [Arguments]    ${documentnaam}    ${ordernummer}    ${kosten}    ${routing}    ${vergoeding}    ${percentage}    ${busmaatschappij}   
    
  3. Open Excel Document   ${DOWNLOAD_FOLDER_PATH}/${documentnaam}.xlsx    docid
    
  4. ${row}=   Set Variable    2
    
  5. FOR    ${index}    IN RANGE    1    20
    
  6.     ${A}=   Read Excel Cell    ${index}    2
    
  7.     IF    "${A}" == "${ordernummer}"
    
  8.         ${row}=   Set Variable    ${index}
    
  9.         Exit For Loop
    
  10.     END
    
  11. END
    
  12. ${busmaatschappij_kolom}=   Read Excel Cell    ${row}    1
    
  13. ${ordernummer_kolom}=       Read Excel Cell    ${row}    2
    
  14. ${kosten_kolom}=            Read Excel Cell    ${row}    3
    
  15. ${routing_kolom}=           Read Excel Cell    ${row}    4
    
  16. ${vergoeding_kolom}=        Read Excel Cell    ${row}    5
    
  17. ${percentage_kolom}=        Read Excel Cell    ${row}    6
    
  18. IF    "${busmaatschappij}" != "null"
    
  19.     Should Be Equal As Strings    ${busmaatschappij_kolom}    ${busmaatschappij}
    
  20. END    
    
  21. Should Be Equal As Strings    ${ordernummer_kolom}    ${ordernummer}
    
  22. Should Be Equal As Strings    ${kosten_kolom}         ${kosten}
    
  23. Should Be Equal As Strings    ${routing_kolom}        ${routing}
    
  24. Should Be Equal As Strings    ${vergoeding_kolom}     ${vergoeding}
    
  25. Should Be Equal As Strings    ${percentage_kolom}     ${percentage}
    
  26. Close Current Excel Document
    
  27. Sleep    1s
    

@EriktenAsbroek Are you using Selenium Library?

No, I am using the Browser library

What happens if you just download the Excel file and skip the interact part? I See jou already did that :thinking:

1 Like

Maybe it has something to do with the fact that Playwright deletes the downloaded files when the browser context that produced them is closed?

1 Like

That seems to be the cause of the problem.
But even when downloading and removing the file (with the Remove File function) without interacting with the document, it still takes a long time to end the test.

BTW do you use Chromium, Google Chrome or Microsoft Edge as browser?

I use Chromium

Hi @Erik Does the following example also takes a long time?
On my machine after the file is downloaded the browser is closed immediately.

Download test
    New Browser    chromium    headless=false
    New Context
    New Page    https://github.com/testsmith-io
    ${link}    Get Element By Role    LINK    name=practice-software-testing
    Click    ${link}
    ${button}    Get Element By Role    BUTTON    name=Code
    Click    ${button}
    ${downloadPromise}    Promise To Wait For Download
    ${downloadButton}    Get Element By    Label    text=Download ZIP
    Click    ${downloadButton}
    ${download}=    Wait For    ${downloadPromise}
    Log    State of download is: ${download}[state]
    Log    File is downloaded at: ${download}[saveAs]
    Close Context
2 Likes

This post gave me enough new ideas :slight_smile:
Fixed it by using the file at ${download}[saveAs] location and using a context instead of only a new browser.
Thanks for the help! :smiley:

1 Like