Skip to content

Releases: drevops/behat-steps

3.5.1

23 Feb 05:22

Choose a tag to compare

What's new since 3.5.0

Full Changelog: 3.5.0...3.5.1

@AlexSkrypnyk, @renovate[bot] and renovate[bot]

3.5.0

27 Jan 00:49

Choose a tag to compare

What's new since 3.4.0

  • 🆕 TimeTrait (Drupal)
    • Control system time in tests using Drupal state overrides
    • When I set system time to :value
      Example: When I set system time to "1737849900"
    • When I reset system time
    • Automatic cleanup after each scenario via @AfterScenario hook
    • Note: Requires a mockable time service in your application. See example implementation

Breaking Changes

  • ⚠️ MetatagTrait namespace changed
    • Before: DrevOps\BehatSteps\Drupal\MetatagTrait
    • After: DrevOps\BehatSteps\MetatagTrait
    • Update your use statements accordingly

Improvements

  • 🔄 PHP 8 Attributes for Hooks [#493]

    • All @BeforeScenario and @AfterScenario annotations converted to PHP 8 attributes
    • Example: #[BeforeScenario] and #[AfterScenario]
    • Affects: BigPipeTrait, BlockTrait, ContentBlockTrait, CookieTrait, EckTrait, EmailTrait, ElementTrait, FieldTrait, FileTrait, MediaTrait, MenuTrait, ParagraphsTrait, TaxonomyTrait, TestmodeTrait, UserTrait, WatchdogTrait
  • 🔄 Mink Exception Classes [#482]

    • Migrated from generic \Exception to Behat\Mink\Exception\ExpectationException
    • Provides better error context and integration with Behat's error handling
    • Affects: CookieTrait, EmailTrait, ElementTrait, FieldTrait, FileDownloadTrait, JavascriptTrait, KeyboardTrait, LinkTrait, PathTrait, ResponseTrait, XmlTrait

Changelog

Full Changelog: 3.4.0...3.5.0

@AlexSkrypnyk, @renovate[bot] and renovate[bot]

3.4.0

19 Nov 04:44

Choose a tag to compare

This release introduces multiple new Behat step definitions, major improvements across existing traits, expanded Drupal module handling, and full XML and responsive testing support — all backed by 100% code coverage across the entire step library.

What's new since 3.3.1

  • 🔄 ContentTrait
    • 🆕 Verical entities format:
      • Given the following :type content blocks with fields:
      • Given the following :type content with fields:
      • Given the following :bundle media with fields:
      • Given the following :vocabulary terms with fields:
      • Given the following users with fields:
    • Example vertical format:
      | title  | [TEST] V-Page 1 | [TEST] V-Page 2 |
      | body   | One             | Two             |
      | status | 1               | 1               |
  • 🔄 CookieTrait
    • Improved driver compatibility enforcement and explicit error messages
  • 🔄 EmailTrait
    • 🆕 New steps:
      • When I send test email to :to with cc :cc with:
        Example: When I send test email to "user@example.com" with cc "copy@example.com" with:
      • When I send test email to :to with bcc :bcc with:
      • When I send test email to :to with cc :cc and bcc :bcc with:
  • 🔄 FieldTrait
    • 🆕 Radio buttons steps:
      • When I choose the radio button :selector
        Example: When I choose the radio button "edit-gender-male"
      • Then the radio button :selector should be selected
      • Then the radio button :selector should not be selected
    • 🆕 Select steps
      • When I unselect :option from :selector
        Example: When I unselect "Administrator" from "edit-roles"
      • When I clear the select :selector
        Example: When I clear the select "field_multi_select"
    • 🐞 Form validation
      • 🐞 Fixed Given browser validation for the form :selector is disabled — registers form selector and disables browser validation automatically after each step
        Example: Given browser validation for the form "#node-article-form" is disabled
      • 🆕 @disable-form-validation — disables browser validation for all forms across the entire scenario
    • 🆕 New date and time handling:
      • When I fill in the datetime field :label with date :date and time :time
        Example: When I fill in the datetime field "Event date" with date "2024-01-15" and time "14:30:00"
      • When I fill in the date part of the datetime field :label with :date
        Example: When I fill in the date part of the datetime field "Event date" with "2024-01-15"
      • When I fill in the time part of the datetime field :label with :time
        Example: When I fill in the time part of the datetime field "Event date" with "14:30:00"
      • When I fill in the start datetime field :label with date :date and time :time
        Example: When I fill in the start datetime field "Event period" with date "2024-01-15" and time "14:30:00"
      • When I fill in the end datetime field :label with date :date and time :time
        Example: When I fill in the end datetime field "Event period" with date "2024-01-20" and time "18:00:00"
  • 🔄 LinkTrait
    • 🐞 Improved error handling when links are missing an href attribute
  • 🆕 ModuleTrait
    • Given the :module module is enabled
      Example: Given the views module is enabled
    • Given the :module module is disabled
    • Then the :module module should be enabled
    • Then the :module module should be disabled
    • Given the following modules are enabled:
    • Given the following modules are disabled:
    • Then the following modules should be enabled:
    • Then the following modules should be disabled:
    • @module:module_name — automatically enables module before scenario begins
      Example: @module:help
    • @module:!module_name — automatically disables module before scenario begins
      Example: @module:!shield
  • 🆕 ResponsiveTrait
    • When I set the viewport to the :breakpoint breakpoint
      Example: When I set the viewport to "mobile_portrait" breakpoint
    • When I set the viewport width to :width
      Example: When I set the viewport width to "480"
    • When I set the viewport height to :height
      Example: When I set the viewport height to "900"
    • When I set the viewport to :width by :height
      Example: When I set the viewport to "1280" by "800"
    • @breakpoint:NAME — automatically applies the named viewport breakpoint before the scenario begins
      Example: @breakpoint:mobile_portrait
  • 🔄 WatchdogTrait
    • Now fails when the watchdog table does not exist
  • 🆕 XmlTrait
    • Then the response should be in XML format
    • Then the response should not be in XML format
    • Then the XML element :element should exist
    • Then the XML element :element should not exist
    • Then the XML element :element should be equal to :text
    • Then the XML element :element should not be equal to :text
    • Then the XML element :element should contain :text
    • Then the XML element :element should not contain :text
    • Then the XML element :element should have :count element(s)
    • Then the XML attribute :attribute on element :element should exist
    • Then the XML attribute :attribute on element :element should not exist
    • Then the XML attribute :attribute on element :element should be equal to :text
    • Then the XML attribute :attribute on element :element should not be equal to :text
    • Then the XML should use the namespace :namespace
    • Then the XML should not use the namespace :namespace

Changelog

Full Changelog: 3.3.1...3.4.0

@AlexSkrypnyk, @renovate[bot] and renovate[bot]

3.3.1

02 Nov 01:23
acd7919

Choose a tag to compare

What's new since 3.3.0

Full Changelog: 3.3.0...3.3.1

@AlexSkrypnyk, @renovate[bot] and renovate[bot]

3.3.0

01 Nov 08:43

Choose a tag to compare

What's new since 3.2.0

New steps

  • @Then the field :field should be empty
  • @Then the field :field should not be empty
  • Assertion for no JS errors on the page - add JavascriptTrait to your FeatureContext.

Updated steps

  • @Then the field :field should be :enabled_or_disabled -> @Then the field :field should have :enabled_or_disabled state

Changelog:

Full Changelog: 3.2.0...3.3.0

@AlexSkrypnyk, @ericgsmith, @renovate[bot] and renovate[bot]

3.2.0

16 Oct 00:11
69928a3

Choose a tag to compare

What's new since 3.1.0

Full Changelog: 3.1.0...3.2.0

@ericgsmith, @AlexSkrypnyk, @renovate[bot] and renovate[bot]

3.1.0

02 Jun 12:26
6eb3123

Choose a tag to compare

What's new since 3.0.0

New steps

  • @Then the element :selector1 should appear after the element :selector2
  • @Then the text :text1 should appear after the text :text2
  • @Then current url should have the :param parameter
  • @Then current url should have the :param parameter with the :value value
  • @Then current url should not have the :param parameter
  • @Then current url should not have the :param parameter with the :value value
  • @When I check the checkbox :selector
  • @When I uncheck the checkbox :selector
  • @Given browser validation for the form :selector is disabled
  • @When I visit the :content_type content revisions page with the title :title
  • @When I visit the :vocabulary_machine_name term page with the name :term_name
  • @When I visit the :vocabulary_machine_name term edit page with the name :term_name
  • @When I visit the :vocabulary_machine_name term delete page with the name :term_name

Updated steps

  • @Then the path should be :path
  • @Then the path should not be :path
  • @When I edit the :vocabulary_machine_name vocabulary :term_name term page

Changelog:

Full Changelog: 3.0.0...3.1.0

@AlexSkrypnyk, @df-nikita, @nsineok, @renovate[bot], @skipper-vp and renovate[bot]

3.0.0 - Consistent language and new namespaces

06 May 09:32
d1cb522

Choose a tag to compare

Consistent language for step definition is here! 🎉

A list of new steps are available in the STEPS.md

We’ve reviewed and updated every step to align with our strict language guidelines. We've also added automated checks to make sure that the step definition are written in a consistent way in the future.

Drupal-specific traits are now namespaced under Drupal/, making it clear that this library is framework-agnostic and suitable for non-Drupal projects as well. More integrations with PHP applications are on the way.

We’ve also added support for Drupal 11, ensuring compatibility with all actively maintained versions.

The testing coverage was increased: we've added positive and negative tests for every trait to guarantee that the tests pass and fail when they expected to do so; we've also added unit tests for some of the traits to check for the most error-prone code.

For migrating from 2.x, please refer to the migration map.

🤖 Expand to get an AI prompt for features migration

Copy and paste below into your agentic AI client chat.

# Guide to Updating Behat Steps Package in Drupal Projects

This guide explains how to update the drevops/behat-steps package to the latest version and update your Behat tests to work with the new step definitions.

## Overview of the Update Process

1. Update the package version in composer.json
2. Update namespace imports in FeatureContext.php
3. Update step definitions in feature files
4. Test and fix each feature file

## Step-by-Step Instructions

### 1. Update the Package

First, check your current version of drevops/behat-steps in composer.json. Then update to the latest version (3.0.1 or newer) using your project's package management tool.

### 2. Fix FeatureContext.php

The namespace structure has changed in version 3.0.1. You'll need to update your FeatureContext.php file:

1. Locate your FeatureContext.php file (typically in tests/behat/bootstrap/)
2. Update the namespace imports at the top of the file
   - Generic traits are now in the root namespace: `DrevOps\BehatSteps\`
   - Drupal-specific traits are now in a subdirectory: `DrevOps\BehatSteps\Drupal\`

For example, change:

    use DrevOps\BehatSteps\ContentTrait;
    use DrevOps\BehatSteps\FieldTrait;
    use DrevOps\BehatSteps\FileTrait;

To:

    use DrevOps\BehatSteps\Drupal\ContentTrait;
    use DrevOps\BehatSteps\Drupal\FieldTrait;
    use DrevOps\BehatSteps\Drupal\FileTrait;

Non-Drupal traits remain in the root namespace:

    use DrevOps\BehatSteps\LinkTrait;
    use DrevOps\BehatSteps\PathTrait;
    use DrevOps\BehatSteps\ResponseTrait;
    use DrevOps\BehatSteps\WaitTrait;

### 3. Consult the STEPS.md File

**This is the most important reference for the update process!**

The drevops/behat-steps package includes a comprehensive STEPS.md file that documents all available steps. After updating the package:

1. Locate this file at `vendor/drevops/behat-steps/STEPS.md`
2. Review this file thoroughly - it contains all available steps with examples
3. Use this as your primary reference when updating feature files

The STEPS.md file is organized into sections:
- Generic steps (Cookie, Date, Element, Path, etc.)
- Drupal-specific steps (Content, Field, File, Media, etc.)

Each section includes detailed examples of how to use the steps, which is invaluable for updating your tests correctly.

### 4. Find and Update Feature Files

Examine your feature files (typically in tests/behat/features/) and update step definitions to match the new format from STEPS.md:

#### Common Changes Needed:

1. **Path Assertions**:
   - Change: `I should be in the "path" path`
   - To: `the path should be "path"`

2. **HTTP Response Assertions**:
   - Change: `I should get a 200 HTTP response`
   - To: `the response status code should be 200`

3. **Response Header Assertions**:
   - Change: `response header "X-Header" contains "value"`
   - To: `the response header "X-Header" should contain the value "value"`

4. **Link Interaction**:
   - Change: `I click the link with title "Title"`
   - To: `I click on the link with the title "Title"` or simply `I click "Title"`

5. **Wait Steps**:
   - Change: `I wait 2 seconds`
   - To: `I wait for 2 seconds`

6. **File Creation**:
   - Change: `unmanaged file "public://file.txt" created with content "content"`
   - To: `the unmanaged file at the URI "public://file.txt" exists with "content"`

7. **Content Visiting**:
   - Change: `I visit content_type "Title"`
   - To: `I visit the "content_type" content page with the title "Title"`

### 5. Reference Available Steps

There are two ways to see all available steps in the new package:

1. **STEPS.md File (Recommended)**: 
   - This is the most comprehensive and user-friendly reference
   - Contains examples and descriptions for each step
   - Located at `vendor/drevops/behat-steps/STEPS.md`

2. **Behat Definitions Command**:
   - Use the Behat definitions command appropriate for your system:
   
       vendor/bin/behat --definitions=i
   
   - This will show all available step definitions but with less context than STEPS.md

Always refer to STEPS.md first, as it provides clearer examples and more detailed information about each step.

### 6. Test Each Feature File

After updating step definitions:

1. Run each feature file individually to identify any issues
2. For failing tests, check screenshots if available to help diagnose the problems
3. Add `@skipped` tag to features that aren't ready to run (you can fix these later)
4. Once individual files pass, run the entire test suite

### 7. Common Troubleshooting

- **Step Not Found**: Verify you're using the current step syntax by checking the step definitions
- **Element Not Found**: The site structure may have changed - update selectors or navigation paths
- **Form Submission Issues**: For form tests, consider checking for broader success indicators rather than specific messages

### Reference Information

The STEPS.md file is your most important reference during this process. It contains:

1. Complete documentation of all available steps
2. Clear examples showing the exact format for each step
3. Descriptions of what each step does
4. Organization by trait/functionality for easy browsing

After updating the package, you should immediately locate and bookmark this file:

    vendor/drevops/behat-steps/STEPS.md

If you need to understand specific Behat step behavior in detail, this file should be your first resource.

## Example: Updating a Contact Form Feature

Before:

    Scenario: User submits a form
      Given I am on the homepage
      And I click the link with title "Contact"
      When I fill in "Name" with "Test User"
      And I press "Send message"
      Then I should see the text "Your message has been sent."

After:

    Scenario: User submits a form
      Given I am on the homepage
      And I click "Contact" 
      When I fill in "Name" with "Test User"
      And I press "Send message"
      Then I should not see an "#edit-submit" element

What's new since 2.7.0

Full Changelog: 2.7.0...3.0.0

@AlexSkrypnyk, @renovate[bot], @skipper-vp, Andrey Simonov and renovate[bot]

2.7.0

24 Mar 10:41
5e3c9ad

Choose a tag to compare

What's new since 2.6.0

Full Changelog: 2.6.0...2.7.0

@AlexSkrypnyk, @renovate[bot], @richardgaunt and renovate[bot]

2.6.0

26 Oct 04:21

Choose a tag to compare

What's new since 2.5.0

Full Changelog: 2.5.0...2.6.0

@AlexSkrypnyk, @renovate and @renovate[bot]