Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (19.7k points)

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 the form

    Given I am on the Form page

    When I fill in "field1" with "value1"

    And I fill in "field2" with "value2"

    And I press "OK"

    Then I should see "Form submitted"

The problem is that I don't have the OK button in the form I need a way to do the "form.submit", without clicking any button or link - the same as happens when you press ENTER when you are in a form field using the browser.

I don't know how to tell capybara to submit a form. How can I do it?

1 Answer

0 votes
by (62.9k points)

You can access the selenium send_keys method to invoke a return event like

find_field('field2').native.send_key(:enter)

You can try sending a newline:

find_field('field2').native.send_key("\n")

Hope this helps!

Browse Categories

...