---
title: Hooks
slug: suite-documentation/h4Up-hooks
docTags: 
createdAt: 2026-01-07T12:09:06.734Z
---

### Hooks (Cucumber)

Hooks is responsible for initializing and managing the Selenium test environment for Cucumber scenarios.Tests are executed on a remote Selenium Grid / Testinium Grid using TestiniumSeleniumDriver.Driver lifecycle is managed using Cucumber hooks, ensuring browser sessions are created and cleaned up automatically.

**Responsibilities**
The Hooks class is responsible for:

- Initializing the WebDriver before each scenario (@Before)
- Selecting the target browser (Chrome / Firefox) via system property (browser)
- Resolving the Selenium Grid URL from configuration sources
- Creating browser-specific options (ChromeOptions / FirefoxOptions)
- Providing shared access to WebDriver and Actions for step definitions
- Quitting the driver after each scenario (@After) to release resources



### Scenario Lifecycle

### @Before beforeScenario()

This method runs before every Cucumber scenario.

It performs:

- Browser selection:
- Grid URL resolution with priority:
- Driver initialization using:
- Actions initialization:

### @After afterScenario()

This method runs after every Cucumber scenario.It ensures:

- The driver is quit (driver.quit())
- Static references are cleared (driver = null, actions = null)
- Selenium Grid resources are released cleanly

This keeps scenario executions isolated and prevents stale sessions.
