Thursday, 26 September 2019

“Howdy” Ruby cucumber Web Automation with Watir

As we Know Cucumber is testing Framework, that used for Writing Acceptance testing for all Web Applications. By Following Basic Concept of Script test Cases in Human Understandable Language.
Here we can See the term, human language, that define plain Form of Structured Languages, that known as Gherkin.
Gherkin is used for Writing Cucumber Feature Files. It has been translated over 70 languages. If you ask, what is the Role of Cucumber here? We can Finish it with a phrase. That Cucumber is an open source tool.
This tool acts like Tough Bridge, that is in between, the test Result and Human Languages. It mainly concentrates on behaviour Driven Development method.
The cucumber Support so many languages like Ruby, Java, and Python.

Identically, cucumber is Integrated and Guided by so many Frameworks like Watir. Ruby on Rails, selenium, capybara. 

What we need

We have to make sure, that have installed ruby on your System.
You can also download the chrome Driver, implement it here.
Now, Extract the Zip File and Make it Executable that is by using the following command.
chmod +x chromedriver
Then move the executable file to bin folder.
sudo mv chromedriver /bin
To get in-depth knowledge on Ruby Cucumber, you can enroll for live Ruby Cucumber online training by OnlineITGuru with 24/7 support and lifetime access
Setup
First, we have to Design a New Project for Cucumber Test.
mkdir cucumber-test
cd cucumber-test
Design a File Name with Germfile and after that add the following Gems to Germfile.
Then Design a File Name with Gemfile and then add the following gems to gemfile.
In addition to that, you get gems her that is http://rubygems.org

gem 'watir'
gem 'RSpec'
gem 'cucumber'
Then Operate Bundle Install to Install Germs for our complete testing Purpose.
$ bundle install
Cucumber – init for setting up Directory Design for Cucumber Project.
cucumber --init
create features
create features/step_definitions
create features/support
create features/support/env.rb
Therefore, add the following lines to features/support/Env.RB file

Here, in env.RB file we are Initializing after and before hooks.
Not to mention, in Starting hook will run the first step of Every Scenario and after hook. They will run the last Step of Every Scenario. When Steps were failed, pending and skipped.
require 'watir'
Before do
@browser = Watir::Browser.new :chrome
@browser.window.maximize
end
After do
@browser.close
end

require 'watir'
Before do
@browser = Watir::Browser.new :chrome
@browser.window.maximize
end
After do
@browser.close
End
Not to mention, here we added water in our Gemfile.
@browser = Watir::Browser.new :chrome -> invoking/opening chrome browser

Gherkin Keywords

But 
And
Then 
When 
Given 
Scenario
Background
Feature
Feature
The Gherkins Files start with keyboard known as Feature. In this section, we describe the functionality of Software Feature. The Description in Feature has no Special Meaning.
It will hold only important points like Software Features. It will not have any impact on Run-time and the Descriptions ignored.
Scenario
A Scenario is one of the core Gherkin Designs. That every Scenario starts with keyword Scenario. That followed by an optional Scenario title. It shows the specific test of Software Function.
It has many Steps that is like cucumber execute every step at a time.

Given
Given Step Describe, Initial State of the system. That when a cucumber executes, the step of the given. It will put the System in a known state before, by user communicating System.
When
When it was used for Describing An action or an Event.
Then
It was used for describing the expected result or an outcome. Then the step utilized like an Assertion for comparing actual outcome and Expected outcome.
But and And 
This will be used, when we use multiple Given, Then and when Statements.
Feature 
In cucumber, every test cases Written in Feature files. Features File will have an Extension of Feature. For the First time of Feature File Starts with a keyboard Feature. Every Feature file has Single Feature.
The feature contains one and many scenarios and In Every Scenario. It contains a sequence of steps. That is likewise Feature keyword used for showing the functionality of the test.
Create Document amazon search. Feature under features/ directory and add few lines.
Feature: Amazon Search functionality
Scenario: searching for mobile phones on Amazon
Given a user goes to Amazon home page
When a user searches for "mobile phones."
Then amazon should return the result for "mobile phones."
These are the best-known facts about Howdy Web Automation with Ruby Cucumber and Waitr.
To get in-depth knowledge on Ruby Cucumber, you can enroll for live Ruby Cucumber online course by OnlineITGuru with 24/7 support and lifetime access

7 comments:

Copyright © 2014 DIGITAL TODAY | Designed With By Blogger Templates
Scroll To Top