Cucumber and Capybara , How to Submit a Form Without a Button

Sometimes We run into  a problem where we need to submit a form after entering data but there is no specific button or link available on which we can perform operation to submit the I am going to suggest few solutions today for these situations in few different ways so that any one can use the solution depending on his specific situation.

Where we can hit "Enter" to submit the form:

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

 Using  java script:

 When /^I submit the form$/ do

 Without Using java Script:

     we can handle this directly using Racktest(Capybara's default driver)
  When /^I submit the "([^\"]*)" form$/ do |form_id|
    element = find_by_id(form_id), element.native).submit :name => nil

Where we cannot hit "Enter" to submit :

  We can click on an element via  by adding the following code   to click on the divs.
 When /^(?:|I )click within "([^"]*)"$/ do |selector|


Popular posts from this blog

Testing Webservice with SoapUI Having Windows Authentication

Data Driven Testing Using Selenium -WebDriver in Python

How to Re-run Failed Scenarios in Cucumber