Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPoison issue on any URL #351

Closed
marnen opened this issue Mar 1, 2018 · 8 comments
Closed

HTTPoison issue on any URL #351

marnen opened this issue Mar 1, 2018 · 8 comments

Comments

@marnen
Copy link

marnen commented Mar 1, 2018

I'm running Wallaby 0.19.2 on a Debian Jessie Docker container (hosted on Mac OS X) with Elixir 1.6. Whenever I do session |> visit(any URL whatsoever), I get the following error:

** (RuntimeError) Wallaby had an internal issue with HTTPoison
    (wallaby) lib/wallaby/httpclient.ex:32: Wallaby.HTTPClient.make_request/4
    (wallaby) lib/wallaby/phantom/driver.ex:151: anonymous fn/2 in Wallaby.Phantom.Driver.visit/2
    (wallaby) lib/wallaby/driver/log_checker.ex:6: Wallaby.Driver.LogChecker.check_logs!/2
    (wallaby) lib/wallaby/browser.ex:703: Wallaby.Browser.visit/2

HTTPoison seems to be retrieving the pages just fine, but I believe the problem is that Wallaby is attempting to decode the resulting HTML as if it were JSON (see https://github.com/keathley/wallaby/blob/v0.19.2/lib/wallaby/httpclient.ex#L54, where the first thing it does is run Poison.decode(body), which fails since the result isn't JSON). Help?

@marnen
Copy link
Author

marnen commented Mar 1, 2018

On reflection, I'm not sure I'm right about the JSON issue, since I suppose Wallaby would have to be making requests to the PhantomJS endpoint, not directly to the desired HTML page. But I definitely can't get Wallaby to visit any page successfully, even though those pages can successfully be seen by a client such as HTTPoison.

@marnen
Copy link
Author

marnen commented Mar 1, 2018

Oh, and I'm using PhantomJS 2.1.1 and setting QT_QPA_PLATFORM=offscreen as recommended here.

@marnen
Copy link
Author

marnen commented Mar 1, 2018

I think I was wrong about the root cause here:

> {status, %HTTPoison.Response{}} = HTTPoison.get session.url
> status
:ok
>  HTTPoison.post session.url, Poison.encode!(%{url: Endpoint.url})
{:error, %HTTPoison.Error{id: nil, reason: :timeout}}

So for some reason the session URL (that's the PhantomJS endpoint, right?) is timing out on POST but not on GET.

@marnen
Copy link
Author

marnen commented Mar 1, 2018

I think there was a twofold problem.

  • I was using the PhantomJS installation from jessie-backports, which doesn't appear to work with Wallaby. I switched to the NPM phantom-prebuilt package.
  • I was also setting QT_QPA_PLATFORM=offscreen as required for PhantomJS 2.1.3. Unfortunately, 2.1.1 (which both backports and the Node package use) doesn't work if I do that.

So...problem solved by switching to phantom-prebuilt and not setting QT_QPA_PLATFORM. Is it worth warning against the jessie-backports version of PhantomJS in the docs?

@PragTob
Copy link
Collaborator

PragTob commented Mar 1, 2018

@marnen thanks for the investigation. It might be worth specifying what version of phantomjs we expect, yes :)

@marnen
Copy link
Author

marnen commented Jul 11, 2018

Not sure why this was closed, given that the docs were never updated...

@keathley
Copy link
Member

If you would like to submit a PR that updates the docs then that would be great. Otherwise we're planning on moving to chrome as the default driver since phantom is deprecated so this problem will be lessened.

@marnen
Copy link
Author

marnen commented Jul 11, 2018

Oh, OK. If this is moot then I won’t bother, but I’ll try to add a sentence or two.

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

No branches or pull requests

3 participants