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

Session issue when working with PhantomJS #70

Open
bigardone opened this Issue Jan 25, 2016 · 7 comments

Comments

Projects
None yet
4 participants
@bigardone

bigardone commented Jan 25, 2016

Hello! I'm using hound to write some integration tests for a Phoenix application with a React/Redux front-end. I' have configured it to use phantomjs and everything works great until I try to set a text into a form field. This is the text file:

defmodule MyApp.SignInTest do
  use MyApp.IntegrationCase

  test "GET /" do
    navigate_to "/"

    assert page_title == "Sign in"
    assert element_displayed?({:id, "sign_in_form"})
  end

  test "Sign in with wrong email/password" do
    navigate_to "/"

    user_email = find_element(:id, "user_email")

    fill_field(user_email, "incorrect@email.com")
  end
end

The first test passes correctly but when it gets to the second one I get this error:

  1) test Sign in with wrong email/password (MyApp.SignInTest)
     test/features/sign_in_test.exs:17
     ** (RuntimeError) Element is not currently interactable and may not be manipulated
     stacktrace:
       (hound) lib/hound/response_parsers/phantom_js.ex:17: Hound.ResponseParsers.PhantomJs.parse/3
       (hound) lib/hound/request_utils.ex:53: Hound.RequestUtils.send_req/4
       (hound) lib/hound/helpers/element.ex:72: Hound.Helpers.Element.fill_field/2
       test/features/sign_in_test.exs:28

The React form is currently rendered so I don't really know if there's anything else I'm actually missing. Any idea? Thanks in advance.

@vitalis

This comment has been minimized.

Show comment
Hide comment
@vitalis

vitalis Mar 14, 2016

Contributor

@bigardone we are currently using hound + phantomjs 2.1.1 in our project and we have no issues with forms in react, I suggest you give it another try. I also suggest to run the phantomjs with log level debug and watch for javascript errors.

Contributor

vitalis commented Mar 14, 2016

@bigardone we are currently using hound + phantomjs 2.1.1 in our project and we have no issues with forms in react, I suggest you give it another try. I also suggest to run the phantomjs with log level debug and watch for javascript errors.

@bigardone

This comment has been minimized.

Show comment
Hide comment
@bigardone

bigardone Mar 14, 2016

Hey @vitalis thanks for your response. I'll give it another try today and share here the results :)

bigardone commented Mar 14, 2016

Hey @vitalis thanks for your response. I'll give it another try today and share here the results :)

@bigardone

This comment has been minimized.

Show comment
Hide comment
@bigardone

bigardone Mar 15, 2016

Hi @vitalis now it's almost working, but there's something going wrong though.
The tests passes but I get the following output:

✗ mix test test/integration/sign_in_test.exs:5
Including tags: [line: "5"]
Excluding tags: [:test]

11:15:10.429 [error] #PID<0.434.0> running Phoenix.Transports.WebSocket terminated
Server: localhost:4001 (http)
Request: GET /socket/websocket?token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJVc2VyOjIxIiwiZXhwIjoxNDU4Mjk2MDI0LCJpYXQiOjE0NTgwMzY4MjQsImlzcyI6IkthaXJvcyIsImp0aSI6IjFiNWNjNDUxLWRlNDQtNDQxMS05MTcyLWI0MGFhYzgzZWQwZiIsInBlbSI6e30sInN1YiI6IlVzZXI6MjEiLCJ0eXAiOiJ0b2tlbiJ9.yccEo7fGUAr-U7PpWpIR-moPF1rEnvCNXZU1MXAlTY3qEX3a9rQemPz5IP2coiR7J1YhWAHvfPYymnCDHDvSXw&vsn=1.0.0
** (exit) an exception was raised:
    ** (UndefinedFunctionError) undefined function nil.id/0
        nil.id()
        (kairos) Kairos.UserSocket.id/1
        (phoenix) lib/phoenix/socket/transport.ex:154: Phoenix.Socket.Transport.connect_vsn/6
        (phoenix) lib/phoenix/transports/websocket.ex:73: Phoenix.Transports.WebSocket.init/2
        (phoenix) lib/phoenix/endpoint/cowboy_websocket.ex:12: Phoenix.Endpoint.CowboyWebSocket.init/3
        (cowboy) src/cowboy_handler.erl:64: :cowboy_handler.handler_init/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
.

Finished in 1.2 seconds (0.2s on load, 0.9s on tests)
3 tests, 0 failures, 2 skipped

That line in the UserSocket module looks like this:

def id(socket), do: "users_socket:#{socket.assigns.current_user.id}"

The thing is that this error doesn't happens while using ChromeDriver or while navigating through the application... is there anything else I must configure in order to use phantomjs that I might have missed?

Thanks in advance :)

bigardone commented Mar 15, 2016

Hi @vitalis now it's almost working, but there's something going wrong though.
The tests passes but I get the following output:

✗ mix test test/integration/sign_in_test.exs:5
Including tags: [line: "5"]
Excluding tags: [:test]

11:15:10.429 [error] #PID<0.434.0> running Phoenix.Transports.WebSocket terminated
Server: localhost:4001 (http)
Request: GET /socket/websocket?token=eyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiJVc2VyOjIxIiwiZXhwIjoxNDU4Mjk2MDI0LCJpYXQiOjE0NTgwMzY4MjQsImlzcyI6IkthaXJvcyIsImp0aSI6IjFiNWNjNDUxLWRlNDQtNDQxMS05MTcyLWI0MGFhYzgzZWQwZiIsInBlbSI6e30sInN1YiI6IlVzZXI6MjEiLCJ0eXAiOiJ0b2tlbiJ9.yccEo7fGUAr-U7PpWpIR-moPF1rEnvCNXZU1MXAlTY3qEX3a9rQemPz5IP2coiR7J1YhWAHvfPYymnCDHDvSXw&vsn=1.0.0
** (exit) an exception was raised:
    ** (UndefinedFunctionError) undefined function nil.id/0
        nil.id()
        (kairos) Kairos.UserSocket.id/1
        (phoenix) lib/phoenix/socket/transport.ex:154: Phoenix.Socket.Transport.connect_vsn/6
        (phoenix) lib/phoenix/transports/websocket.ex:73: Phoenix.Transports.WebSocket.init/2
        (phoenix) lib/phoenix/endpoint/cowboy_websocket.ex:12: Phoenix.Endpoint.CowboyWebSocket.init/3
        (cowboy) src/cowboy_handler.erl:64: :cowboy_handler.handler_init/4
        (cowboy) src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
.

Finished in 1.2 seconds (0.2s on load, 0.9s on tests)
3 tests, 0 failures, 2 skipped

That line in the UserSocket module looks like this:

def id(socket), do: "users_socket:#{socket.assigns.current_user.id}"

The thing is that this error doesn't happens while using ChromeDriver or while navigating through the application... is there anything else I must configure in order to use phantomjs that I might have missed?

Thanks in advance :)

@vitalis

This comment has been minimized.

Show comment
Hide comment
@vitalis

vitalis Mar 15, 2016

Contributor

@bigardone
I think it's session related issue, phantomjs uses same cookie jar for all sessions:
https://github.com/HashNuke/hound#phantomjs-caveats
you can try to use Hound.Helpers.Cookie.delete_cookies() to clear previous session data

Contributor

vitalis commented Mar 15, 2016

@bigardone
I think it's session related issue, phantomjs uses same cookie jar for all sessions:
https://github.com/HashNuke/hound#phantomjs-caveats
you can try to use Hound.Helpers.Cookie.delete_cookies() to clear previous session data

@bigardone

This comment has been minimized.

Show comment
Hide comment
@bigardone

bigardone Mar 15, 2016

Thanks for the response. I thought it was something related to that and I added the call to delete_cookies() at the end of the test but the result is still the same though :(

bigardone commented Mar 15, 2016

Thanks for the response. I thought it was something related to that and I added the call to delete_cookies() at the end of the test but the result is still the same though :(

@danhper danhper changed the title from Element is not currently interactable and may not be manipulated to Session issue when working with PhantomJS Mar 16, 2016

@danhper

This comment has been minimized.

Show comment
Hide comment
@danhper

danhper Apr 3, 2016

Collaborator

Hi @bigardone,
Are you still having some troubles? If you still are, if would be great if you could provide us a minimal example to reproduce the issue so that we can help you better.
Thank you!

Collaborator

danhper commented Apr 3, 2016

Hi @bigardone,
Are you still having some troubles? If you still are, if would be great if you could provide us a minimal example to reproduce the issue so that we can help you better.
Thank you!

@darksheik

This comment has been minimized.

Show comment
Hide comment
@darksheik

darksheik Apr 3, 2016

Contributor

Sorry for my removed comment - I didn't read the whole thread.

Contributor

darksheik commented Apr 3, 2016

Sorry for my removed comment - I didn't read the whole thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment