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

undefined method `switch_to' #80

Closed
lucascaton opened this issue Jun 11, 2012 · 7 comments

Comments

@lucascaton
Copy link

commented Jun 11, 2012

I'm trying to use this code:

page.driver.browser.switch_to.alert.accept

It works with Selenium, but not when I use Poltergeist:

NoMethodError:
  undefined method `switch_to' for #<Capybara::RackTest::Browser:0x007fafff8841e8>

Is there other way to accept the confirm JS dialog?

@jonleighton

This comment has been minimized.

Copy link
Contributor

commented Jun 11, 2012

That's a Selenium-specific API, so no surprise it doesn't work with Poltergeist. Also, the error you've shown indicates you are using the RackTest driver rather than Poltergeist.

Poltergeist always returns true for a call to window.confirm. There's no way to make it return false (at the moment), but it should not prevent your test from running.

@lucascaton

This comment has been minimized.

Copy link
Author

commented Jun 12, 2012

Thank you @jonleighton!

@lucascaton lucascaton closed this Jun 12, 2012
@gbirchmeier

This comment has been minimized.

Copy link

commented Aug 16, 2012

I want to retain the ability to use Firefox if needed, and I'm finding this rule works out alright:

When /^I confirm a popup$/ do
  page.driver.browser.switch_to.alert.accept unless Capybara.javascript_driver == :poltergeist
end

Since Poltergeist can't dismiss a popup, though, I guess I can't test what happens when someone says no to the confirm dialog.

@mjobin-mdsol

This comment has been minimized.

Copy link

commented Sep 13, 2012

how about pop windows? we have links that opens in a separate window.
with selenium we are able to do page.driver.browser.switch_to.window( window_handle )

anything similar in poltergeist?

@auvi

This comment has been minimized.

Copy link

commented Jun 15, 2013

Yes, anything about popup windows? I can do it with Selenium.

@denzilv

This comment has been minimized.

Copy link

commented Jun 24, 2013

I'm looking to do something similar as well. I guess we'll have to use Selenium for these particular use cases for the meantime.

@aceofbassgreg

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.