teampoltergeist / poltergeist

A PhantomJS driver for Capybara
MIT License
2.5k stars 415 forks source link

Timeout when using within_frame although iFrame seems to be loaded #878

Closed waldofe closed 7 years ago

waldofe commented 7 years ago

I'm trying to use the following code to access an iFrame scope.

within_frame(find(:css, "iframe#z_hppm_iframe")) do
  # ...
end

And I'm getting (already tried using high timeout values):

Capybara::Poltergeist::TimeoutError:
       Timed out waiting for response to {"id":"9d43c2b8-81cb-44b7-8811-03ab7a5beea9","name":"push_frame","args":[[3,104]]}. It's possible that this happened because something took a very long time (for example a page load was slow). If so, setting the Poltergeist :timeout option to a higher value will help (see the docs for details). If increasing the timeout does not help, this is probably a bug in Poltergeist - please report it to the issue tracker.

Debug log seems to stop on push_frame step:

{"id":"22372385-d9f5-432a-887e-2094751cd99b","name":"find","args":["css","iframe#z_hppm_iframe"]}
{"command_id":"22372385-d9f5-432a-887e-2094751cd99b","response":{"page_id":3,"ids":[104]}}
{"id":"c216229c-8cb8-4082-8b6a-971e78c973b5","name":"visible","args":[3,104]}
{"command_id":"c216229c-8cb8-4082-8b6a-971e78c973b5","response":true}
{"id":"9d43c2b8-81cb-44b7-8811-03ab7a5beea9","name":"push_frame","args":[[3,104]]}

More information on the iFrame being loaded:

screen shot 2017-03-28 at 11 19 20 pm

Obs.: When using save_and_open_page I can see that the iFrame is already loaded.

Tried on:

twalpole commented 7 years ago

What version of Capybara and PhantomJS?

waldofe commented 7 years ago

Thanks for the quick answer @twalpole! Capybara 2.13 and PhantomJS 2.1.1.

twalpole commented 7 years ago

@oswaldoferreira This probably won't fix the issue, but just an FYI -- rather than using a find in within_frame you can just pass it the id of the frame you're looking for and it will use the :frame selector to locate it.

within_frame("z_hppm_iframe") do
  # ...
end
twalpole commented 7 years ago

@oswaldoferreira Does sleeping for a few seconds before calling within_frame make a difference?

waldofe commented 7 years ago

Already tried using about 30 seconds, but no changes.

FYI, it's working on capybara-webkit 1.14.

twalpole commented 7 years ago

@oswaldoferreira I haven't been able to replicate this, although from reading the code I would guess that either the frame page is requesting a resource that is hanging ( throttled, etc ) or there is a race condition in the page loading. Could you turn on the phantomjs_options: ['--debug=true'] option in your driver registration and/or blacklist/whitelist the resources the page is requesting, and let me know if that provides any more info.

twalpole commented 7 years ago

or (of course) a minimal reproducible example :)

twalpole commented 7 years ago

@oswaldoferreira I created a new 'frame_timeout' branch with debugging info around the frame changing code, please give it a try and let me know what it outputs

twalpole commented 7 years ago

Closing due to lack of response, we will reopen if/when the requested info is provided.