YusukeIwaki / capybara-playwright-driver

Playwright driver for Capybara
MIT License
154 stars 13 forks source link

How to handle/increase timeout #57

Closed ankitsinghaniyaz closed 1 year ago

ankitsinghaniyaz commented 1 year ago

I'm randomly getting this error in my tests

Playwright::TimeoutError:
       TimeoutError: Timeout 30000ms exceeded.
       =========================== logs ===========================
       navigating to "http://127.0.0.1:42245/forms/7/builder", waiting until "load"
       ============================================================

In my configuration I've increased the timeout to be 60000ms but still getting the same errors, seems like it's not respected?

Here's how my settings look like:

Capybara.register_driver(:playwright) do |app|
  Capybara::Playwright::Driver.new(app,
    browser_type: :chromium, # :chromium (default) or :firefox, :webkit
    headless: true, # true for headless mode (default), false for headful mode.
    timeout: 60_000 # ms
  )
end

I've also set the max timeout

Capybara.default_max_wait_time = 60 # seconds

Any pointers would help.

ankitsinghaniyaz commented 1 year ago

Any help would be appreciated on this.

YusukeIwaki commented 1 year ago

Thank you for you kind proposal. I'm afraid that I don't know whether Capybara Selenium driver behaves similarly or not. Do you know how?

ankitsinghaniyaz commented 1 year ago

@YusukeIwaki, I didn't get your question. What do you mean?

YusukeIwaki commented 1 year ago

I am sorry for late response. (I was very busy and don't afford to maintain this gem in these days...)

I checked the behavior of Capybara + Selenium, and it seems that visit does not timeout even when Capybara. default_max_wait_time = 1. Selenium Webdriver timeouts after 30 seconds with a Net::ReadTimeout exception. and Capybara doesn't provide a configuration for extend the read_timeout. Users must configure WebDriver directly to extend the read timeout.

My opinion is that we have to configure Playwright directly for extending visit timeout on capybara-playwright-driver.

YusukeIwaki commented 1 year ago

Oops, my misunderstanding... Capybara::Selenium::Driver takes timeout parameter for configure read_timeout. https://github.com/teamcapybara/capybara/blob/master/lib/capybara/selenium/driver.rb#L70

Currently Capybara::Playwright::Driver uses the timeout for chromium.launch(timeout:) and it is not compatible with Selenium driver. The reasonable solution for this issue is to respect the timeout for defining default navigation timeout.