Baffling RSpec/Capybara test problem with apparently blank response bodies

Recently a new kind of test flakiness has emerged that I’ve not seen before, and I’m struggling to get to the bottom of it. In the following scenario, sometimes those last expectations hit a blank response body, and sometimes not. When they do, we get a Capybara::ElementNotFound: Unable to find visible xpath "/html". Yet if I log all response bodies in Rails, and tail the logs I can see no instance where we are returning a blank body. Any suggestions of possible causes or ways of debugging this much appreciated! Have lost hours on this one already.

      scenario "admin searches for permission by destination title" do
        expect(page).to have_css("#republication_permissions tbody tr", count: 5)

        within ".permission_filter" do
          fill_in "Search republication permissions", with: search_item.destination_title
          click_on "Search permissions"
        end

        expect(page).to have_text("Search completed")
        expect(page).to have_css("#records_count", text: "1")

We experienced something similar. We’ve pinned the version of chrome in our GitHub actions Chrome 134 breaks Selenium tests - intermittent failures with visit(visit_uri) · Issue #2800 · teamcapybara/capybara · GitHub

1 Like

Thanks so much for this reply! I’ll try pinning ours to the previous version and see if that resolves this.