• Home
  • Testing
  • SAP
  • Web
  • Must Learn!
  • Big Data
  • Live Projects
  • Blog

Test Scenario: Verify output when Email id is not entered

Test Steps:

  1. Open Browser
  2. Go To http://demo.guru99.com/
  3. Do not enter Email id
  4. Click Submit

Expected Result: Error is shown

 

 

Step 1) Open komodo Editor via windows start menu

Your First Cucumber Script

You will See Komodo Dashboard as below

Your First Cucumber Script

 

Step 2) Now we have to create a

  1. new feature file in feature folder
  2. step definition file in step _definitions folder

Create a New file From the File > New > New File

Your First Cucumber Script

Step 3) Save File in "yourfolder/features/" with name "yourfilename.feature"

Your First Cucumber Script

Step 4) To execute our scenario, save the following commands in the Feature File

Your First Cucumber Script

Step 5) Now lets Run our First feature file.!

Click on "Start Command Prompt With ruby"

 

Step 6) Type "cucumber yourfolder/your feature file path and press enter

Your First Cucumber Script

It will look like this!

Your First Cucumber Script

You see the error because you have to write step definitions file for feature file

Step 7) Lets create step definition file for our Feature File!

Create a new file in komodo editor

Your First Cucumber Script

Step 8) Save File As below in "yourfolder/features/step_definititons" with name test_step.rb

Your First Cucumber Script

Step 9) Write the following code into the step file

Your First Cucumber Script

Above code will call the gems we have installed.

Next add Step Definitions For Scenario as below:

Your First Cucumber Script

Step 10) Now, again run our feature file:

 

Your First Cucumber Script

The result is

Your First Cucumber Script

Step 11) Lets code the next scenario

Test Scenario: Verify output when Email id is not entered

Test Steps:

  1. Open Browser
  2. Go To http://demo.guru99.com/
  3. Do enter Email id
  4. Click Submit

Expected Result: Error is shown

let's write feature and scenarios as below for this testing

Your First Cucumber Script

And write step definitions as below for this scenario:

Your First Cucumber Script

Run feature file from ruby cmd

Your First Cucumber Script

 

Sample code of feature file:

Feature: guru99 Demopage Login

In order to Login in Demopage we have to enter login details

Scenario: Register On Guru99 Demopage without email

Given I am on the Guru99 homepage

When enter blank details for Register

Then error email shown

Scenario: Register On Guru99 Demopage with valid email

Given I am on the Guru99 homepage

When enter details for Register

Then login details shown

Sample of of step definition file for this feature file:

require 'watir-webdriver'

require 'colorize'

browser = Watir::Browser.new

Given (/^I am on the Guru99 homepage$/)do

browser.goto "http://demo.guru99.com"

end

When (/^enter blank details for Register$/)do

browser.text_field(:name,"emailid").set(" ")

browser.button(:name,"btnLogin").click

end

Then (/^error email shown$/)do

puts " Email is Required".red

browser.close

end

When (/^enter details for Register$/)do

browser = Watir::Browser.new

browser.goto "http://demo.guru99.com"

browser.text_field(:name,"emailid").set("This email address is being protected from spambots. You need JavaScript enabled to view it.")

browser.button(:name,"btnLogin").click

end

Then (/^login details shown$/)do

puts " Sucessfully register"

browser.close

end