Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8107781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T00:53:10+00:00 2026-06-06T00:53:10+00:00

I am writing request specs … I use Capybara… And I am in trouble

  • 0

I am writing request specs … I use Capybara… And I am in trouble with some modal windows.

What I actually want in my test is to fill in a form that pops up in a modal window.

The modal is created with Bootstrap from Twitter (http://twitter.github.com/bootstrap/javascript.html#modals)… and it’s going through a set of transitions (but I don’t know if this is relevant to what I’m about to say).

I have tried a few workarounds I found on the web, like:

A) switching between pages with page.driver.browser.window_handles

page.driver.browser.switch_to.window(page.driver.browser.window_handles.last)

B) using wait_until to make sure that the modal loads

def modal_wrapper_id
  '#modal-edit'
end

def modal_visible
  wait_until { find(modal_wrapper_id).visible? }
rescue Capybara::TimeoutError
  flunk 'Expected modal to be visible.'
end

but none of those worked… so I thought to render the number of window handles at the moment when the modal window is active…

So I did this:

puts page.driver.browser.window_handles.length.should == 2 

And I got this:

Failure/Error: page.driver.browser.window_handles.length.should == 2
           expected: 2
           got: 1 (using ==)

From what I understand, practically my modal window doesn’t exist.

Any help on this one would be much appreciated.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T00:53:12+00:00Added an answer on June 6, 2026 at 12:53 am

    I didn’t use Capybara, but your problem has to do with the fact that Bootstrap’s modal dialog is actually a pseudo-modal, in that it’s actually just a div element and a transparent overlay behind it. A true modal dialog would be one created using window.confirm, for example, which can indeed be queried using your sample code. In your case you should give the modal div element an id, and use that as a handle to query it from Capybara and wait until its display is “block”. Didn’t test anything though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a server running as a Windows service that by request invokes Firefox
I'm not going to use other module like request , how about writing this
I am writing a windows filesystem minifilter driver that must fail I/O Request Packets
It's so clumsy to always be writing Request.Form[blah]... is there any sort of way
I'm writing a plugin and trying to request some data from a custom table
I'm writing a server who starts a thread for each incomming request. I want
I am writing an Ajax request form with Ruby on Rails using a collection_select
I started writing with magento. I have to do some ajax request for my
I am writing in request of some suggestions for some well-designed open source Java
I'm writing a servlet that handles each request by accessing and modifying some table(s)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.