poltergeist


How does one test the content of confirm dialogs using poltergeist?


The capybara-webkit driver allows you to test the content of any confirm dialog messages that are triggered by the app. Is there a way to do this in poltergeist?
It's not supported in poltergeist now but there's a workaround to check the content manually.
In our project we use a helper method to override the javascript confirm function, store the message and check the content.
# helper method
def handle_js_confirm
page.evaluate_script 'window.confirmMsg = null'
page.evaluate_script 'window.confirm = function(msg) { window.confirmMsg = msg; return true; }'
yield
page.evaluate_script 'window.confirmMsg'
end
# usage
handle_js_confirm do
click_link 'Trigger javascript confirm'
end.should == 'Are you sure?'
P.S. There is an github issue discussing about this, though it's a 2 years long conversation, you can keep reading on https://github.com/jonleighton/poltergeist/issues/50

Related Links

How can I use “includeJs” function of phantomjs with poltergeist?
Poltergeist ruby gem fails to process `:shift` modifier in `send_keys`
Using Poltergiest to give user of app a screenshot of their page
Poltergeist 1.9.0 w/Ruby 1.9.3
Post via Capybara and Poltergiest for API testing
Poltergeist current_url command is returning page_info hash instead of a URL
How does one test the content of confirm dialogs using poltergeist?
Using Poltergeist, Phantom JS instances are not exiting during every rspec run
Render page element with padding in Poltergeist
Can I monkey patch the phantomjs browser api with execute_script?
send_keys support for Poltergeist?

Categories

HOME
image
layout
relative-path
objectgears
webstorm
gis
jsrender
icloud
google-project-tango
disassembler
node-notifier
medical
slurm
primary-key
maude-system
alignment
percona
evopdf
openedx
nas
language-agnostic
jndi
icloud-api
linkerd
libssl
madlib
socialengine
phonegap
scorm2004
framemaker
vsts-build-task
amazon-kinesis-kpl
force-layout
hexo
restlet
starteam
sharefile
sas-visual-analytics
unoconv
android-tabhost
botbuilder
estimote
http-redirect
flashair
businessworks
parentheses
hibernate-tools
chain-builder
zip4j
pebble-watch
spring-cache
trash
websitepanel
essence
dataview
bluegiga
php-internals
hsv
vhd
retina
libressl
jqgrid-formatter
kcachegrind
composite
bitcoinj
p4java
hippomocks
marmalade
hyprlinkr
viadeo
gwt-rpc
twrequest
subscript
eclipse-templates
deobfuscation
locate
iphone-web-app
coda-slider
preference
nsviewanimation
meego
dbisam

Resources

Encrypt Message