好吧,所以我的問題是水豚不能單擊提交按鈕的窗體(生成與簡單的形式),駐留在模式(Bootstrap V2.3) 。請注意,以下代碼是非常混亂的學習者代碼。我試圖讓它測試,以便我可以重構它。水豚無法點擊表單按鈕在模態和不同的水豚司機看到不同的東西
模態代碼:
<div class="modal hide" id="updateModal">
<button type="button" class="close" data-dismiss="modal">×</button>
<div class="modal-header"
<h3>Update your score</h3>
</div>
<div class="modal-body">
<%= 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 class="modal-footer">
<%= 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" do
before do
sign_in #omniauth fake signin
end
subject { 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
end
end
所以我這樣做,當我檢查什麼save_and_open_page
看到其頁面完全沒有改變。沒有證據表明按鈕被按下了。所以我認爲生成的js模式可能會出現問題,所以我在describe
行中添加了, :js => true
,安裝webkit驅動程序並將Capybara.javascript_driver = :webkit
添加到我的spec_helper.rb
文件並再次運行。
這次我在迎接在主頁上的塊之前從頂部「登錄」閃光,而不是在排名頁面上。
所以我認爲這可能會變得更好與硒驅動程序,所以我安裝並再試一次,但這次我的應用程序抱怨沒有人註冊了這一輪。發生這種情況的唯一方法是,如果@entrants
是零,並且我已經用pry檢查過,至少就數據庫而言絕對不是這種情況。
任何幫助你們可以給予將是GREATLY讚賞。我不知道如何讓這個東西按下我的按鈕。
要清楚的是,沒有':js => true'的嘗試會得到最接近的結果,但它似乎無法按下按鈕,原因不明。 – SomberClock
是的,如果點擊「更新」運行Javascript你需要一個Javascript驅動程序,所以我們不會擔心非Javascript結果。我不明白爲什麼不同的Javascript驅動程序給出了不同的結果。請明確您現在使用的錯誤,以及您掌握的步驟。 –
@SomberClock請準備一個示例應用程序(只是一套HTML/JS/Ruby代碼等),可以重現此問題。這將大大幫助其他人調查和修復它。 –