Accessing popup windows
A fairly common practice in authentication of Twitter apps via OAuth is to redirect to the authorize endpoint in a popup window. I'm not able to use Selenium to fully test because it doesn't handle redirects (AFAIK), but mechanize doesn't handle popup windows
main, popup = page.driver.browser.window_handles
within_window(popup) do
# fill in login info here and click authorize
end
Any suggestions on how to handle this or if it would be possible to add window handling to capybara-mechanize? Thanks.
I believe this has been fixed since the 1.0 release.
No kidding? @ryansch thanks for helping to clear out the backlog. I'll try to add a test for this.
Does it work?
page.driver.browser.window_handles (version 1.4.0)
undefined method 'window_handles ' for #Capybara::Mechanize::Browser
It worked as of the 1.1.0 release with capybara 2.1.0. Sounds like we might have a regression.
I will try like you said, thanks
@ryansch For this, the method window_handles should be here, on 1.1.0.
https://github.com/jeroenvandijk/capybara-mechanize/blob/v1.1.0/lib/capybara/mechanize/browser.rb
or not?
Not there. Notice how the class inherits from Capybara::RackTest::Browser? That should lead you to it.
I'm assuming this broke due to changes in Capybara.
I'm saying this, because when i use capybara-webkit, it works.
At master there, the method exist: https://github.com/thoughtbot/capybara-webkit/blob/c1b501ca525532d261ded8d3c0c6408716a1f8ef/lib/capybara/webkit/browser.rb#L129
Right they wrote their own browser. Capybara-mechanize is a special kind of racktest driver.
I'm interested in that deprecation warning. I'm fairly certain that's the real cause of this issue. What version of capybara are you running?
With webkit: gem 'capybara', '2.1.0' gem 'capybara-webkit', '1.0.0'
With mechanize i tried, but didn't work: gem 'capybara', '2.1.0' gem 'capybara-mechanize', '1.1.0'
Something strange is going on then. We're using the second stanza in our app right now and we make pretty heavy use of page.driver.browser.window_handles.
I will try again, will check it outside my app, maybe it is a something else, then i come back here. Thank you.