capybaracuprite

How to inspect modal text with Cuprite?


I'm switching from the Poltergeist to Cuprite driver for Capybara.

I have Javascript code which sets the message for a confirmation modal which I want to check in my feature specs.

The javascript is confirm("....").

With Poltergiest I could do page.driver.browser.modal_message.

This is unsupported by Cuprite, it there another way?


Solution

  • Capybaras accept_confirm (which cuprite supports) returns the string from the system modal:

    text = accept_confirm do
       # ... the actions that triggers the modal to appear
    end
    

    Or you can pass a string to accept_confirm to have it verify the string:

    accept_confirm('the text to check') do
       # ... the actions that triggers the modal to appear
    end