-3

ruby cucumber を使用して多数のフォーム フォームに入力しようとしていますが、nil:NilClass (NoMethodError) に対して未定義のメソッド「form」を取得しています。最初のページではフォームに正しく記入しますが、2 ページ目ではエラー メッセージが表示されます。

コード

Then /^next page Licence Type: "(.*)", Licence Years: "(.*)", NCD: "(.*)"$/ do |licence_type, licence_years, ncd|
   step 'I wait "1" seconds'
   frame = @browser.frames.find{ |frame| frame.form(:action => "Default.aspx?Action=nav&Page=5047").exists? }
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").select(:id => "ctl03_content-216088_drivinglicencetype-213533_dd").select licence_type
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").select(:id => "ctl03_content-216088_drivinglicenceyears-213534_dd").select licence_years
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").select(:id => "ctl03_content-216088_ncd-for-new-models-767231_dd").select ncd
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").select(:id => "ctl03_content-216088_nrofclaims-213540_dd").select "None"
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").select(:id => "ctl03_content-216088_nrofconvictions-220190_dd").select "None"
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").radio(:id => "ctl03_content-216088_usualpaymentmethod-231551_rbRadioList_0").click
   frame.form(:action => "Default.aspx?Action=nav&Page=5047").button(:id => "ctl03_navigation-216089_table-261670_row-261671_next-261674_next-261675_pbNext").click
   step 'I wait "1" seconds'
end


Then /^next page 2 Mileage: "(.*)", Car Value: "(.*)" & Overnight Location: "(.*)"$/ do |mileage, car_value, overnight_location|
  frame = @browser.frames.find{ |frame| frame.form(:method => "post").exists? }
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").select(:id => "ctl03_content-231405_car-details-231421_annualmileage-231427_dd").select mileage
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").text_field(:id => "ctl03_content-231405_car-details-231421_vehiclevalue-231426_tb").set car_value
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").text_field(:id => "ctl03_content-231405_car-details-231421_purchase-date-231428_MONTH").set "01"
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").text_field(:id => "ctl03_content-231405_car-details-231421_purchase-date-231428_YEAR").set "2008"
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").select(:id => "ctl03_content-231405_car-details-231421_garage-231424_dd").select overnight_location
  frame.form(:action => "Default.aspx?Action=nav&Page=5322").button(:id => "ctl03_navigation-231432_copy-of-table-261677_row-261678_next-261681_next-261682_pbNext").click
  step 'The page Assumptions containing the following text'
  frame.form(:action => "post").button(:id => "ctl03_navigation-279445_copy-of-copy-of-table-279454_row-279455_next-279458_next-279459_pbNext").click
  step 'I wait "1" seconds'
  price =  frame.form(:action => "Default.aspx?Action=nav&Page=5334").div(:id, "premiumprice-882008").exist?
  puts price
  puts assert price.eql? (true)
end
4

1 に答える 1

0

が原因でこのエラーが発生しますframe-nilが付いたフォームのフレームが見つかりませんでした:method => "post":action => "Default.aspx?Action=nav&Page=5322"おそらく、最初の例のように、アクションによってフォームを探す必要があります。または、検索する前に待機ステップを追加する必要があるかもしれません。これらは、私が見ることができる実際の例との唯一の違いです。

また、フォームを変数に割り当てて、繰り返しなどを繰り返さないようにすることを強くお勧めしますframe.form(:action => "Default.aspx?Action=nav&Page=5047")-yuk!

于 2012-12-11T13:40:31.050 に答える