模态代码:
<div ID="updateModal"><button type="button" data-dismiss="modal">×</button> <div <h3>Update your score</h3> </div> <div > <%= simple_form_for @update do |f| %> <%= render 'shared/error_messages',object: f.object %> <%= f.input :newread,:label => "Amount Read",:placeholder => 'pages/screens/minutes #',:input_HTML => { :maxlength => 5 } %> <%= f.input :medium,:label=> "Medium Read",:collection => ["book","manga","game","fgame","net","lyric","subs","news","sent","nico" ],:prompt => "Select medium read" %> <% lang_List = Update::user_langs(current_user,ApplicationHelper::curr_round) %> <%= f.input :lang,:label => "Language",:collection => lang_List,:prompt => "Select your language" %> <%= f.input :repeat,:label => "Repeat number",:collection =>0..50,:priority => '0' %> <%= f.input :dr,:inline_label => 'Double Rowed?',:hint => 'Only to be used with Japanese books',:label => false %> </div> <div > <%= submit_tag 'Cancel',:class => "btn btn-danger",'data-dismiss' => "modal" %> <%= f.button :submit,'submit Update',:class => "btn btn-primary"%> </div> <% end %></div>
圆控制器索引功能:
def index @entrants = Round.includes(:user).where(:round_ID => "#{ApplicationHelper::curr_round}") if @entrants == nil redirect_to root_url,:flash => { :error => "There are currently no users registered for this round." } end List = Round.where(:round_ID => ApplicationHelper::curr_round).select(:tIEr).uniq lang_List = Update.where(:round_ID => ApplicationHelper::curr_round).select(:lang).uniq @tIEr = List.map(&:tIEr) @tIEr = @tIEr.sort{ |a,b| TIEr::TIER_VALUES[a.to_sym] <=> TIEr::TIER_VALUES[b.to_sym]} @lang = lang_List.map(&:lang) if signed_in? @update = current_user.updates.build end end
Update_page_spec:
describe "Update Pages" dobefore do sign_in #omniauth fake signinendsubject { page } describe "a registered user submitting an update",:Js => true do before do user = User.find_by_uID(123545) user_round = user.rounds.create!(round_ID: ApplicationHelper::curr_round,lang1: 'jp',lang2: 'en',lang3:'zh',tIEr: 'bronze',book: 10,manga: 10,fgame: 10,game: 10,net: 10,news: 10,lyric: 10,subs: 10,nico: 10,sent:10,pcount: 1010) visit round_path(ApplicationHelper.curr_round) end it "should update successfully" do click_link("Update") fill_in('update[newread]',:with => '10') select "book",:from => "Medium Read" select "Japanese",:from => "Language" click_button "submit Update" save_and_open_page page.should have_selector('alert-success',:text => "Update successfully submitted") end endend
所以我这样做,当我检查save_and_open_page看到了什么,它的页面没有任何变化.没有按钮被按下的证据.所以我认为生成Js的模态可能是个问题所以我添加:Js =>如果对于describe行,请安装webkit驱动程序并将Capybara.JavaScript_driver =:webkit添加到我的spec_helper.rb文件并再次运行.
这次我在主页上阻止了从顶部开始的“登录”闪光,而不是在排名页面上.
所以我想也许这可能会更好用selenium驱动程序,所以我安装并再次尝试,但这次我的应用程序抱怨没有人注册该轮.发生这种情况的唯一方法是,如果@entrants为零,我已经检查过pry,至少就数据库而言,这绝对不是这种情况.
你们给予的任何帮助都将非常感激.我不知道如何按下我的按钮.
解决方法 我的建议:>尽可能多地清理代码.这将有助于澄清正在发生的事情,以及可能导致意外行为的原因.
>不要依赖save_and_open_page来准确地向您显示驱动程序正在看到的内容
>你肯定需要Bootstrap modal的Js
>让硒与firefox一起工作,这样你就可以在屏幕上看到模态是否正常打开.
>您可能需要database_cleaner gem才能与您正在创建的用户正确访问您的数据库.
>你也可以尝试使用兼容Js兼容驱动程序的poltergeist / phantom gems.那是screenshot capabilities
这些作品应该告诉你模态发生了什么.
总结以上是内存溢出为你收集整理的ruby-on-rails-4 – Capybara无法点击模态中的表单按钮,不同的水豚驱动程序看到不同的东西全部内容,希望文章能够帮你解决ruby-on-rails-4 – Capybara无法点击模态中的表单按钮,不同的水豚驱动程序看到不同的东西所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)