Closed Papipo closed 5 years ago
@Papipo Thanks! Is the popup an alert or confirmation dialog? If so then you might look at these functions: https://github.com/keathley/wallaby/blob/v0.19.2/lib/wallaby/browser.ex#L760.
Let me know if I'm not understanding your specific use case correctly.
I was talking about windows opened with things like window.open()
. Although right now I am not entirely sure about this approach. I think that it could be better to use something like bypass and stub the result of the Oauth flow.
Are you using something like uberauth?
Yes, that's what I plan to use, and I saw on their issue tracker a mention to bypass. I don't know if there is any other option.
Typically with uberauth I use the identity provider in development and test and have users log in through that.
I don't think that fits my use case. I really want to use my ueberauth configuration for each provider. I still don't know how to mock this. Only if I could redirect /auth/provider to /auth/provider/callback on my tests...
So the core issue is that your trying to log in and it’s opening a new window instead of redirecting the page, and you need a way to interact with that new window?
Yes, that was the original problem, how to interact with a new window with Wallaby.
For now, I have come up with a solution that I don't like in order to be able to redirect requests to /auth/provider to /auth/provider/callback:
The problem is that this setup won't work when I want to test with multiple sessions, I think.
This is theoretically possible to do with this functionality: https://www.w3.org/TR/webdriver/#dfn-switch-to-window. We already support getting window handles internally in chrome. We would just need to extend this functionality. This is NOT supported by phantom so I'm not sure how we should handle this from an api perspective.
This is what I've been using for switching windows with Selenium:
import Wallaby.HTTPClient
# ...
def focus_window(session, window_handle) do
{:ok, _} =
request(:post, "#{session.url}/window", %{handle: window_handle, name: window_handle})
session
end
Hi!
I don't really know how to tackle an OAuth authentication step that happens on a popup. With Capybara, for example, you can access the driver and from there its windows. I haven't found a way to do that with Wallaby.
Apart from that, this is an awesome library, thanks!