I am writing query specifications ... I am using Capybara ... And I am having problems with some modal windows.
What I really want in my test is to fill out the form that appears in the modal window.
The modal is created using Bootstrap from Twitter ( http://twitter.github.com/bootstrap/javascript.html#modals ) ... and it goes through a set of transitions (but I don’t know what has to do with what I'm going to say )
I tried several workarounds that I found on the Internet, for example:
A) switch between pages from 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 them worked ... so I decided to display the number of window handles when the modal window was 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 does not exist.
Any help on this would be greatly appreciated.
Thanks.
adritha84
source share