私はキュウリで自分のPHP Webアプリケーションをテストしようとしているうちに問題に遭遇しています。基本的に、button_pressメソッドは、フォームの送信時にbuttonName_xおよびbuttonName_y POST変数を送信できません。webratのbutton_pressのPOST変数がありません
私は誰かが私にこれを手伝ってくれることを願っています - ありがとうございました!
編集:私は、問題を一時的に解決できるように、webratの汚れたパッチを書くことができました。しかし、私はまだもっと良い解決策を聞いてうれしいです。
<form id="newsForm" action="/index.php?page=adminpanel&view=newscontrol" method="post">
<table cellpadding="0" cellspacing="0" class="tableList">
<thead id="editor">
<tr>
<th colspan="3">News Editor</th>
</tr>
</thead>
<tbody>
<tr class="rowA">
<td colspan="3">Titel: <input type="text" name="subject" value="'.utf8htmlentities($subject).'" size="121" /></td>
</tr>
<tr class="rowB">
<td colspan="3">
<textarea id="content" name="content" rows="10" cols="10">'.utf8htmlentities($content).'</textarea>
</td>
</tr>
<tr class="submitRow">
<td colspan="3"><input type="image" src="res/images/design/button_preview.gif" name="previewNews" alt="preview" /> <input type="image" src="res/images/design/button_sendx.gif" name="submitNews" alt="submit" /></td>
</tr>
</tbody>
</table>
</form>
失敗特徴の抽出
:一方array(2) { ["content"]=> string(22) "Magnificient News Post" ["subject"]=> string(18) "This is a subject!" }
:
Scenario: post news
[...]
When I insert "This is a subject!" for newsForm.subject
And I insert "Magnificient News Post" for newsForm.content
And I press newsForm.submit
[...]
のvar_dump($ _ POST)がもたらした
この
は、問題のhtmlですfirefox経由でのリクエスト: 次のように0array(4) { ["content"]=> string(22) "Magnificient News Post" ["subject"]=> string(18) "This is a subject!" ["submitNews_x"]=> string(1) "0" ["submitNews_y"]=> string(1) "0" }
私のステップの定義が見える:
When /^I insert "(.*?)" for (.*?)\.(.*?)$/ do |input, form, item|
within 'form[id="' + form + '"]' do |scope|
scope.fill_in(item, :with => input)
end
end
When /^I press (.*?)\.(.*?)$/ do |form, item|
within 'form[id="' + form + '"]' do |scope|
scope.click_button(item)
end
end
そして最後に、私のenv.rb:
# RSpec
require 'rspec/expectations'
# Webrat
require 'webrat'
require 'test/unit/assertions'
World(Test::Unit::Assertions)
Webrat.configure do |config|
config.mode = :mechanize
end
class MechanizeWorld < Webrat::MechanizeAdapter
include Webrat::Matchers
include Webrat::Methods
Webrat::Methods.delegate_to_session :response_code, :response_body, :response, :redirected_to
end
World do
MechanizeWorld.new
session = Webrat::Session.new
session.extend(Webrat::Methods)
session.extend(Webrat::Matchers)
session
end
ありがとう、私はそれをします。 –