I'm using Capybara, the selenium-webdriver gem, and chromedriver in order to drive my javascript enabled tests.
The problem is that about 50% of our builds fail due to a Net::ReadTimeout
error. At first this was manifesting as a 'could not find element' error, but after I upped Capybara's default max wait time to 30 seconds, I started seeing the timeout.
I examined the screenshots of when the timeout happens, it's stuck on a 'Successfully logged in' modal that we show briefly before using the Javascript function, location.reload()
, to reload the page.
I've ran the test locally and can sometimes reproduce it, also randomly. Sometimes it zips by this modal and does the reload so fast you can barely see it, and other times it just hangs forever.
I don't feel like it's an asset compilation issue, since the site has already loaded at that point in order for the user to access the login form.
Wondering if anyone has seen this before and knows a solution.
The specific code:
visit login_path page.within '#sign-in-pane__body' do fill_in 'Email', with: user.email click_button 'Submit' end expect(page).to have_content 'Enter Password' page.within '#sign-in-pane__body' do fill_in 'Password', with: user.password click_button 'Submit' end expect(page).to have_text 'Home page landing text'
The hang up happens between click_button 'Submit'
and expecting the home page text.
The flow of the logic causing the timeout is the user submits the login form, we wait for the server to render a .js.erb
template that triggers a JS event upon successful login. When that trigger happens we show a modal saying that login was successful, then execute a location.reload()
.
Capybara.server
set to?Capybara.server
to anything it defaults to Webrick which can have issues with multiple simultaneous requests. Try settingCapybara.server = :puma
and see if that makes a difference.visit path
.