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")