Check text in the field in Capybara

I am using rspec and capybara for testing with rails 4.0

After sending the ajax request, a warning window is displayed. I want to check the warning box text in my specification. Is there any way to check it out?

+3
source share
1 answer

You can only do this if you are testing Capybara using a javascript driver such as Selenium or Poltergeist. Using rspec / capybara and selenium, you can do it like this:

text = page.driver.browser.switch_to.alert.text
expect(text).to eq 'Message you are looking for'

, , , , , . , .

+3

All Articles