Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python - Playwright timeout

I'm using Playwright to upload a file and download the result. When the inputfiles are large, and it takes a long time to process I get a timeout from playwright; it takes to long for the button "Download" to appear.

    raise exception
playwright._impl._api_types.TimeoutError: Timeout 30000.0ms exceeded while waiting for event "download"
=========================== logs ===========================
waiting for event "download"
============================================================

How can I let playwright wait longer on that specific event?

with page.expect_download() as download_info:
    page.locator("text=Download").click()
    #todo: wait longer?
download = download_info.value
# expect(page).to_have_url("http://localhost:8080/swagger/#/NER/post_ner")
path = download.path()
suggested_filename = file_out
download.save_as(suggested_filename)
like image 686
Tralala Avatar asked Apr 27 '26 22:04

Tralala


1 Answers

If you know that the click will take a while, you can set a timeout:

page.locator("text=Download").click(timeout=60000)
like image 63
hardkoded Avatar answered Apr 30 '26 13:04

hardkoded



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!