I’m trying to implement a request spec using Capybara, RSpec and JS (using Webkit). I have a test that sends of a JS request (jQuery.load) which will return a page, which will be embedded in the existing page.
When I debug the test with pry it runs through. When it runs on it own it fails. I guess this is due to the added time given when using pry. Is there a way I can force Cabypara to retry for a certain time?
My test code looks as follows:
describe "load list for given period", js:true do
it "loads the last entry" do
page.fill_in "period_value", with: "1"
page.select "Entries", from: "period_unit"
page.click_link "update_list_section"
page.all(:xpath, "//div[@id='list_section_wrapper']/table/tbody/tr").count.should == 2
end
end
Because the element already exists upon request the
Capybara.default_wait_timedoes not work i.e. capybara doesn’t wait/retry. I had to put in a hardsleep(0.5)for it to work.Was all nicely explained in this blog post (as soon as I entered the right keywords into the googlez).