Cucumber, capybara and selenium - Submitting a form without a button

后端 未结 12 1902
挽巷
挽巷 2021-02-01 18:14

I have a test using Cucumber, capybara and selenium driver. This test should go to a form and submit it. The normal text would be

  Scenario: Fill form
    Give         


        
12条回答
  •  感情败类
    2021-02-01 18:59

    I just had to solve this problem myself. In webrat I had something like this:

    Then /^I submit the "([^\"]*)" form$/ do |form_id|
      submit_form form_id
    end
    

    I was able to achieve the same thing with this in Capybara:

      Then /^I submit the "([^\"]*)" form$/ do |form_id|
        element = find_by_id(form_id)
        Capybara::RackTest::Form.new(page.driver, element.native).submit :name => nil
      end
    

提交回复
热议问题