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

1

0

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?

Gravure answered 10/12, 2013 at 4:7 Comment(0)
M
0

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

Mun answered 13/12, 2013 at 4:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.