ruby on rails - Fill in an input text in a modal popin -
i'm triing test modal form cucumber/capybara. modal loaded after page rendering. input text not found.
here sourcecode.
the view rendering modal
<div class="modal hide fade" id="mymodal" tabindex="-1" role="dialog" data-backdrop="static" style="width:600px; padding:30px">loading...</div> <script type="text/javascript"> $(document).ready(function() { $('#mymodal').modal('show'); $('#mymodal').html("<%= j render("form")%>"); }); </script>
the modal contains input text
<input id="project_title" name="project[title]" type="text" value="">
the test (i have tried differents methods in comments)
# find(:css, "#project_title").set value # within("#mymodal") # find(:css, "#project_title", visible: false).set value # end # sleep 3 find(:css, "#project_title", visible: false).set value
the error unable find css "#project_title" (capybara::elementnotfound) have tried put input text in div test selector, works good. so, problem modal form.
thanks help.
eric
it might take times trigger modal after document ready. increase chance, may prolong default wait time (which 2 seconds default).
capybara.default_wait_time = 10
hope help.
Comments
Post a Comment