Reputation: 1
When running tests, a Net::ReadTimeout (Net::ReadTimeout) error occurs. The error occurs only in situations of switching to a new window.
At the same time, the problem is not even in the exception itself, but in the consequences. The fact is that when a problem occurs, the test does not fall, and a decent time (up to 10 minutes) waits before is crashed.
At the same time, there are no exceptions in the server console and browser console.
I use Capybara (selenium), chromediver 102.0.5005.61 and chrome .
client = Selenium::WebDriver::Remote::Http::Default.new
client.read_timeout = 80
options = Selenium::WebDriver::Chrome::Options.new
options.add_preference('profile.content_settings.exceptions.automatic_downloads', {
'*': {'setting': 1}
})
Capybara::Selenium::Driver.new(app, :browser => :chrome, http_client: client, options: options)
It is code to switch to new window
window_last = page.driver.browser.window_handles.last
log window_last
page.driver.browser.switch_to.window(window_last)
There is a hook that should work, it seems to work, but for some reason it does not interrupt the test
After do |scenario|
if scenario.failed?
filename = scenario.location.file.split('/').pop.split('.').shift
path = "#{ENV['ROOTDIR']}/06_Reports/error/#{filename}#{scenario.id}.png"
p path
page.save_screenshot path
end
page.driver.browser.close
page.driver.quit()
end
It seems to me that it started after updating chrome and chromedriver - but I'm not sure. It is not possible to repeat it manually, it is possible to run the autotest, and far from the first attempt.
Any idea what it is, where to dig? How to prevent such freezes? They greatly increase the run time.
Thank you!
Upvotes: 0
Views: 304
Reputation: 49870
If it started after updating chrome/chromedriver then it's likely a bug in chromedriver. Try rolling back to a previous version of chrome and seeing if the issue goes away. One thing to note is that by switching windows directly on the driver you are preventing Capybara from knowing about the window switch which can lead to issues. You should instead use the Capybara::Session#switch_to_window
or within_window
methods to do window switching.
Upvotes: 0