我正在尝试使用 ruby cucumber 填写一些表单,但我得到了 nil:NilClass (NoMethodError) 的未定义方法“form”。在第一页上,它正确填写了表格,但在第二页上,我收到了错误消息。
代码
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