Skip to content
This repository has been archived by the owner. It is now read-only.

Support accepting javascript confirmation dialogs #50

Closed
atambo opened this issue Apr 19, 2012 · 27 comments
Closed

Support accepting javascript confirmation dialogs #50

atambo opened this issue Apr 19, 2012 · 27 comments

Comments

@atambo
Copy link

@atambo atambo commented Apr 19, 2012

Selenium allows you to:

page.driver.browser.switch_to.alert.accept

How can I do something like the above with poltergeist?

@jonleighton
Copy link
Contributor

@jonleighton jonleighton commented Apr 19, 2012

Poltergeist ignores alerts/confirms by default. If that's not happening it's a bug, but I think it just works. (This is also what capybara-webkit does.)

@monfresh
Copy link

@monfresh monfresh commented Sep 3, 2013

Is there a way to know whether an alert did appear to begin with? I'm trying to test that user-provided input is sanitized, so that if they change their name to <script>var x = 1;alert(x)</script>, it doesn't run the script. I want to be able to confirm that an alert appeared when the code does not do the sanitization (i.e a failing test). Is that possible?

@monfresh
Copy link

@monfresh monfresh commented Sep 3, 2013

I ended up using capybara-webkit for this by using page.driver.alert_messages to determine if any alerts are present. Does Poltergeist have an equivalent?

@route
Copy link
Member

@route route commented Sep 3, 2013

I'll reopen it as a reminder to check it, come back as soon as possible

@route route reopened this Sep 3, 2013
@jherdman
Copy link

@jherdman jherdman commented Nov 4, 2013

Any progress on this?

@route
Copy link
Member

@route route commented Nov 4, 2013

I didn't have time to look into this yet, if anyone has please go ahead

@sirvine
Copy link

@sirvine sirvine commented Nov 15, 2013

It would also be nice to have the ability to send keyboard input to JS prompt dialogs (and get their text content), as per Selenium's Alert class: https://github.com/vertis/selenium-webdriver/blob/8f4aefa604e76b24085c91f70f97a093e40a08d6/lib/selenium/webdriver/common/alert.rb

@mkarklins
Copy link

@mkarklins mkarklins commented Dec 4, 2013

Would be nice if Poltergeist implemented something similar to page.driver.alert_messages

@michaelglass
Copy link

@michaelglass michaelglass commented Jan 25, 2014

here's what I've been doing in my tests

kind of janky but it works.

I don't know if I wrote this or stole it.

https://gist.github.com/michaelglass/8610317

@gamov
Copy link

@gamov gamov commented Feb 18, 2014

👍

@vizcay
Copy link

@vizcay vizcay commented Apr 29, 2014

+1 This will be really useful!

@thedelchop
Copy link
Contributor

@thedelchop thedelchop commented Apr 30, 2014

Next week I am on vacation and will try to see if we can implement this since it seems to be getting a lot of interest.

@rickmzp
Copy link

@rickmzp rickmzp commented May 2, 2014

+1

4 similar comments
@mgmorcos
Copy link

@mgmorcos mgmorcos commented May 2, 2014

+1

@tsgautier
Copy link

@tsgautier tsgautier commented May 2, 2014

+1

@paulcruz
Copy link

@paulcruz paulcruz commented May 2, 2014

+1

@lubert
Copy link

@lubert lubert commented May 7, 2014

+1

@yaauie
Copy link
Member

@yaauie yaauie commented May 7, 2014

If someone submits a pull-request, we will be glad to review it & get the feature merged. Comments with "+1" don't do anything to drive this feature forward since @teampoltergeist/committers doesn't really have the resources to do feature-request-driven development.

@marnen
Copy link

@marnen marnen commented Jul 3, 2014

@michaelglass Thank you. That looks like it will work for me for now, though I wish this were in Poltergeist for real.

@michaelglass
Copy link

@michaelglass michaelglass commented Jul 3, 2014

@marnen yer welcome! super janky but such is life.

@mjgiarlo
Copy link

@mjgiarlo mjgiarlo commented Jul 3, 2014

@michaelglass Paraphrasing Rumsfeld re: janky code:

As you know, you go to production with the code you have, not the code you might want or wish to have at a later time.

🍻

@serioushaircut
Copy link

@serioushaircut serioushaircut commented Sep 10, 2014

I'd (still) love to see that generically in poltergeist

@route
Copy link
Member

@route route commented Sep 10, 2014

I think @gongo is doing great job for all of us #516

@route route closed this Sep 10, 2014
@badosu
Copy link

@badosu badosu commented May 26, 2015

@michaelglass solution works very well until a proper fix is pushed.

This should be referenced somewhere as it would have saved a lot of time for me.

@Bastes
Copy link

@Bastes Bastes commented Jun 2, 2016

@michaelglass Waiting for a proper implementation in poltergeist, this is an awesome solution ^^ kudos sir, you've made my and my teammate's day ^^d

@twalpole
Copy link
Contributor

@twalpole twalpole commented Jun 2, 2016

@Bastes Poltergeist has had support for Capybaras modal api since September 2015 - you shouldn't need to be including anything else. If it's not working for you please open a new issue with details.
http://www.rubydoc.info/github/jnicklas/capybara/Capybara%2FSession%3Aaccept_alert

@Bastes
Copy link

@Bastes Bastes commented Jul 1, 2016

@twalpole Indeed it works ^^ could benefit from a little publicity too imo, I'll see if I can send a pull request with a little something in the readme. Thanks ^^d

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet