- create test directory (mkdir test)
- \curl -L https://get.rvm.io | bash -s stable —ruby
- gem install cucumber
- gem install capybara
- mkdir features\support
- mkdir features\step_definitions
Capybara settings
Create env.rb file under support folder with following content
require 'capybara/cucumber'
Capybara.default_driver = :selenium
Cucumber scenarios
Create test.feature file under features folder
Feature: Find the automationhints blog
Scenario: Search for the blog
Given I am on the Google homepage
Then I will search for "automationhints.blogspot"
Then I should see "Vijay Ragavan"
Step definitions for cucumber steps
Create my_steps.rb file under step_definitions directory.
Given(/^I am on the Google homepage$/) do
visit 'http://www.google.co.in'
end
Then(/^I will search for "([^"]*)"$/) do |arg|
fill_in 'gbqfq', :with => arg + "\n"
end
Then(/^I should see "([^"]*)"$/) do |text|
page.should have_content(text)
end
RUN
Navigate to test folder in console and type command as "cucumber". it will run all scenarios which is part of feature files.
No comments:
Post a Comment