0

We have some tests written in Capybara (Ruby) + SitePrism + ChromeDriver.

In some of those test, there is a page involved which has some very slow-loading iframes and which is causing the tests to fail with Net::ReadTimeout exceptions.

I know that I can increase the timeout to wait for longer, but this would increase the total execution time of the tests by a big factor.

Also, we don't really care about the iframes themselves, only for the rest of the elements in that page.

Is there any way to tell Capybara to not wait for the iframes to load?

If that's not possible, would at least be possible to wait some predefined time and if that time expires, simulate a stop-page-loading (like pressing the escape button in an actual browser)?

Alex Ntousias
  • 8,962
  • 8
  • 39
  • 47

1 Answers1

1

The cleanest solution for issues like that when using the selenium driver is to use a programmable proxy like puffing-billy https://github.com/oesmith/puffing-billy to block the requests and return errors or static content. If you were using Poltergeist or capybara-webkit you could use their white/blacklist support to do the same thing.

Thomas Walpole
  • 48,548
  • 5
  • 64
  • 78
  • While I was searching for a solution to our problem, I came across puffing-billy as a potential fix. Unfortunately we cannot use any additional libraries. Could you give me some examples of the non-so-clean ways of doing the same thing? – Alex Ntousias Feb 28 '17 at 09:00
  • @Alex Write your own proxy code, increase the timeout, modify the page source in test mode so it doesn't load the frames, etc. They're all bad solutions. Puffing-billy is a tool that helps you write better more performant tests and while I completely understand a policy of not adding any additional libraries to the production environment, a policy that also prevents you from adding useful tools to the test environment is mildly insane. – Thomas Walpole Feb 28 '17 at 15:49
  • I totally agree with you, but unfortunately there's not much I can do to change that! I ended up going with the increased page-load timeout. – Alex Ntousias Mar 01 '17 at 06:33