Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Cucumber Cookbook
  • Table Of Contents Toc
Cucumber Cookbook

Cucumber Cookbook

By : Shankar Garg
3.7 (3)
close
close
Cucumber Cookbook

Cucumber Cookbook

3.7 (3)
By: Shankar Garg

Overview of this book

This book is intended for business and development personnel who want to use Cucumber for behavior-driven development and test automation. Readers with some familiarity with Cucumber will find this book of most benefit. Since the main objective of this book is to create test automation frameworks, previous experience in automation will be helpful.
Table of Contents (8 chapters)
close
close
7
Index

Tagging the Hooks

What if we want to execute some piece of code only before certain Scenarios and not before all Scenarios? Consider a situation where we want to invoke the Selenium Webdriver for the Scenarios related to browser automation and the REST Client code for Scenarios related to REST Services automation. How do we do this in Cucumber? Let's see this in the next section.

Getting ready

For this recipe, we are going to use update home_page.feature like this:

Feature: Home Page

  Background: flow till home page
    Given user is on Application home page

  @web
  Scenario: Home Page Default content on Web
    Then user gets a GitHub Bootcamp section

  @rest
  Scenario: GitHub account REST Service
    When user sends a GET request

How to do it…

  1. Update the code of the Hooks.java class with the following code:
    package com.automation;
    
    import org.openqa.selenium.WebDriver;
    
    import cucumber.api.java.After;
    import cucumber.api.java.Before;
    
    public class Hooks {
    
      public static...
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Cucumber Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon