Wallaby with OAuth Logins

So I’m trying to write a pretty basic integration test that clicks a login link, fills in an instagram login, and returns to a logged in home page. Finding and clicking the login link works, but when I get to the instagram login page the session seems to hang. Here’s the entirety of my test:

defmodule LinxtaWeb.LandingPageTest do
  use LinxtaWeb.FeatureCase, async: true

  import Wallaby.Query

  test "can log in", %{session: session} do
    |> visit("/")
    |> find(css(".landing"))
    |> assert_has(css(".cta", text: "Start Here"))
    |> click(css(".cta"))
    # Instagraph login page? Hangs here.
    |> fill_in(text_field("username"), with: "sometestusername")
    |> fill_in(text_field("password"), with: "sometestpassword")
    |> click(button("Log in"))

I’m using the Chrome driver and when I turn off headless mode the browser seems to be correctly loading the instagram page. I assume that I’m missing something obvious.

My google fu might be a bit weak but I haven’t found anything indicating that this should be a tricky thing to pull off.

Any thoughts/pointers would be rad. Thanks!

I have no idea about the issue, but you can pass --remote-debugging-port=9222 to chrome and visit localhost:9222 to debug the page while it’s hanging (you might need to have a chrome window open before starting the test).

I passed chrome: [ headless: false ] to the config and can see the window stalled out on the Instagram login page, but there are no errors to speak of, it’s as if the commands are blocked somewhere after the page loads.

I wonder if it has something to do with loading a new page or hitting a different domain.

I have no idea - I understood that it would hang (as in page is not loading) when running headless but not when running regular. Have you tried placing an assert for something in instagram’s page after the click? I imagine it won’t do anything though…

1 Like

Yeah, it’s tough to tell because either the assert works and nothing happens or the assert never fires and nothing happens. Ah well. I’ll come back to it later and see if there’s something obvious I’m missing.

If I come up with a solution I’ll post it here. Thanks, mate!