Skip to content
This repository has been archived by the owner on Nov 27, 2020. It is now read-only.

Poltergeist raises Timeout even after page is loaded #468

Closed
npassaro opened this issue Mar 13, 2014 · 10 comments
Closed

Poltergeist raises Timeout even after page is loaded #468

npassaro opened this issue Mar 13, 2014 · 10 comments

Comments

@npassaro
Copy link

Hi,

I am using poltergeist with capybara to do some tests. You can see the initialization here:

def scenario_start(scenario_id = '', timeout= 60, debug= true)
    Capybara.run_server = false
    Capybara.javascript_driver = :poltergeist
    Capybara.default_wait_time = 60
    Capybara.register_driver :poltergeist do |app|
      Capybara::Poltergeist::Driver.new(app, { :debug => debug, :timeout => timeout, :phantomjs_options => ['--ignore-ssl-errors=yes', '--proxy-type=none'] })
    end
    Capybara.reset_sessions!

    @counter = []
    @session = Capybara::Session.new(:poltergeist)

  end

After this, I try to do a login, the loading is slow but about 12s average. I've already tried tweaking poltergeist timeout init variable but to no avail...

When the Timeout exception is raise a screenshot is taken of the last visited page and I can see the full page in the image. I have already incresead the time out up to 400...

Will start to cry in about 1 hour....

@npassaro
Copy link
Author

After loads of crying and tissue wasting, I have found out that the problem is associated with phantomjs and its onLoadFinished not firing.

@route
Copy link
Contributor

route commented Dec 22, 2014

@npassaro I didn't catch have you solved an issue?

@npassaro
Copy link
Author

Hi! Most of the text was desperation talking.
I didn't correct any issue, I found out that the problem was not with poltergeist. So, i closed the issue.

It is an already known problem(it seemed) with the implementation of phantomjs's webkit websockets.

@route
Copy link
Contributor

route commented Dec 22, 2014

Gotcha! Thank you!

@andymantell
Copy link

@npassaro I know this was nearly 3 years ago now, but do you recall the phantomjs issue that you were referring to? Or what the resolution was? I have a page that is showing as fully loaded but it's almost like phantomjs is waiting for the open websocket connection to finish, which of course it never does.

@npassaro
Copy link
Author

npassaro commented Jul 5, 2017

That was exactly the issue.

I haven't look at this for a long time but as I remember there is a javascript event that is triggered when the page finishes loading, i.e. onLoadFinished.

For what I understood, and I might be completely wrong, this event is independent of the websocket connection. However, phantomjs 1.9.x used an implementation of Webkit that used an implementation of the websocket standard that was not the standard that won. For some reason, the old Webkit would hang waiting for the websocket to close in order to trigger onLoadFinished. For the user, this is not a problem, the page loads. For the tester, this means that there was no way to know when to validate the DOM since the page "is never loaded".

I this issue is related to this: ariya/phantomjs#11018

See here: https://stackoverflow.com/questions/30302359/phantomjs-not-rendering-angular-websockets-page

@andymantell
Copy link

@npassaro Thanks. I managed to fix it in the end by not initialising the websocket straight away. Instead I now initialise it on the window load event. This means that phantomjs sees that the page has loaded and then the websocket is opened.

@twalpole
Copy link
Contributor

twalpole commented Jul 9, 2017

@andymantell I believe using PhantomJS 2.1.1 and switching to using puma as the "server" (Capybara.server = :puma) should let websockets work correctly.

@andymantell
Copy link

Ah thanks @twalpole, I'll give that a try. Hadn't heard of Puma before

@marnen
Copy link

marnen commented Aug 10, 2017

@twalpole Thanks for the recommendation. Switching to Puma is helping me with a similar issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants