PHPackages                             lexsoft/drupal-behat-contexts - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. lexsoft/drupal-behat-contexts

ActiveTesting-tools[Testing &amp; Quality](/categories/testing)

lexsoft/drupal-behat-contexts
=============================

Simple context to help debugging tests with some steps.

1.0(7y ago)013GPL-2.0-or-laterPHPPHP &gt;=5.3.0

Since Jul 5Pushed 7y agoCompare

[ Source](https://github.com/lexsoft00/drupal-behat-contexts)[ Packagist](https://packagist.org/packages/lexsoft/drupal-behat-contexts)[ RSS](/packages/lexsoft-drupal-behat-contexts/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

Drupal Behat Contexts
=====================

[](#drupal-behat-contexts)

Contexts that we use with Behat 3.x tests on Drupal sites.

How?
----

[](#how)

- The tool can be installed easily with composer.
- Defining the formatter in the `behat.yml` file
- Modifying the settings in the `behat.yml`file

Installation
------------

[](#installation)

### Prerequisites

[](#prerequisites)

This extension requires:

- PHP 5.3.x or higher
- Behat 3.x or higher

### Through composer

[](#through-composer)

The easiest way to keep your suite updated is to use [Composer](http://getcomposer.org%3E):

#### Install with composer:

[](#install-with-composer)

```
$ composer require --dev lexsoft/drupal-behat-contexts
```

#### Install using `composer.json`

[](#install-using-composerjson)

Add DrupalBehatContexts to the list of dependencies inside your `composer.json`.

```
{
    "require": {
        "behat/behat": "3.*@stable",
        "drupal/drupal-extension": "3.*@stable",
        "lexsoft/drupal-behat-contexts": "1.*",
    },
    "minimum-stability": "dev",
    "config": {
        "bin-dir": "bin/"
    }
}
```

Then simply install it with composer:

```
$ composer install --dev --prefer-dist
```

You can read more about Composer on its [official webpage](http://getcomposer.org).

Configure
---------

[](#configure)

Each context may have its own configuration, see each context section.

Contexts
--------

[](#contexts)

### DebugContext

[](#debugcontext)

Simple context to help debugging tests with some steps. Additionally, it hooks in the after step event to add a step that generates an error report on failed steps.

This report includes:

- A file with the HTML page content.
- A file with the current URL and the error exception dump.
- If available, a file with current page state.

#### Steps

[](#steps)

- Then capture full page with a width of :width

    Saves a screenshot of current page with the given width to a file.
- Then capture full page with a width of :width with name :filename in configured directory (screenshots\_path).

    Saves a screenshot of current page with the given width to a given filename in configured directory (screenshots\_path).
- Then capture full page with width of :width to :path

    Saves a screenshot of current page with the given width to a file in the given path. If path is relative screenshots\_path config value is used as root.
- Then capture full page with width of :width to :path with name :filename

    Saves a screenshot of current page with the given width to a file in the given path to a given filename. If path is relative screenshots\_path config value is used as root.
- Then save last response

    Saves page content to a file.
- Then save last response to :path

    Saves page content to a file in the given path.
- Then save last response to :path

    Halts test for a given amount of seconds. Useful when debugging tests with timing issues. Don't use this step in real tests.

#### Configuration

[](#configuration)

Add DebugContext to your suite.

This is an example when bootstrap directorty is in DRUPALROOT/sites/all/tests/behat/bootstrap.

```
default:
  autoload:
    '': %paths.base%\tests\features\bootstrap # This works with windows for linux change the path
  suites:
    default:
      paths:
        - %paths.base%\tests\features # This works with windows for linux change the path
      contexts:
        - Drupal\DrupalExtension\Context\DrupalContext
        - Drupal\DrupalExtension\Context\DrushContext
        - Drupal\DrupalExtension\Context\MessageContext
        - Drupal\DrupalExtension\Context\MinkContext
        - Drupal\DrupalExtension\Context\MarkupContext
        - lexsoft\DrupalBehatContexts\Context\UIContext
        - lexsoft\DrupalBehatContexts\Context\DrupalOrganicGroupsExtendedContext
        - lexsoft\DrupalBehatContexts\Context\DrupalExtendedContext
        - lexsoft\DrupalBehatContexts\Context\BrowserSizeContext:
            parameters:
        - lexsoft\DrupalBehatContexts\Context\DebugContext:
            parameters:
              'report_on_error': true
              'error_reporting_path': "%paths.base%\\tests\\errors\\reports\\" # This works with windows for linux change the path
              'screenshots_path': "%paths.base%\\tests\\errors\\screenshots\\" # This works with windows for linux change the path
              'page_contents_path': "%paths.base%\\tests\\errors\\pages\\" # This works with windows for linux change the path
```

**Parameters**

- report\_on\_error: If *true* error reports are generated on failed steps.
- error\_reporting\_path: Path where reports are saved.
- screenshots\_path: Path where screenshots are saved. Report screenshots are saved in the report path, here only screenshots from *capture full page* steps are saved.
- page\_contents\_path: Path where page contents are saved. Report page contents are saved in the report path, here only page contents from *save page content* steps are saved.

### BrowserSizeContext

[](#browsersizecontext)

This contexts allows to resize the browser to a given set of sizes. It should be used with a real browser driver like Selenium. Its main purpose is to ease tests that depends on window size.

Keep in mind that browser window size may not change between scenarios or features, even differnet test execution. For example, if you use PhantomJS the same browser is used for all tests execution (given that PhantomJS is not terminated and executed again). So if a test changes the window size next tests with the @javadcript tag will be performed with that window size.

#### Steps

[](#steps-1)

- Given (that )browser window size is :size size

    Changes window broeser size to the given size. The size must be one of the default ones or one of the sizes declared in the configuration.

#### Configuration

[](#configuration-1)

Add BrowserSizeContext to your suite.

To declare sizes and make them available use the context params:

```
- lexsoft\DrupalBehatContexts\BrowserSizeContext:
    parameters:
      sizes:
        Default:
          width: 1200
          height: 800
        Full:
          width: 1200
          height: 800
        My custom size:
          width: 1440
          height: 960
```

The context has some default values. If a size is defined with same name as one of the default sizes the dimensions are overwritten. If a completely new size is defined is simply added to the available size.

### DrupalExtendedContext

[](#drupalextendedcontext)

This context extends DrupalRawContext with steps related to Drupal and its modules.

#### Steps

[](#steps-2)

- Then form :type element :label should be required

    Checks a form element is required. File input type is not supported.
- Then form :type element :label should not be required

    Checks a form element is required. File input type is not supported.
- Given I run elysia cron

    Runs Elysia cron.

#### Configuration

[](#configuration-2)

No configuration needed.

### IUContext

[](#iucontext)

This context provides steps for certain UI elements.

#### Steps

[](#steps-3)

- Given I select :option from :select chosen.js select box

    Selects and option from a Chosen select widget. Only for sinlge selection, it doesn't work with multiple selection enabled or tag style.

    See

#### Configuration

[](#configuration-3)

No configuration needed.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2916d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3879243?v=4)[lexsoft](/maintainers/lexsoft)[@lexsoft](https://github.com/lexsoft)

---

Top Contributors

[![rsanzante](https://avatars.githubusercontent.com/u/776453?v=4)](https://github.com/rsanzante "rsanzante (68 commits)")[![jorgetutor](https://avatars.githubusercontent.com/u/1230268?v=4)](https://github.com/jorgetutor "jorgetutor (27 commits)")[![omarlopesino](https://avatars.githubusercontent.com/u/3202817?v=4)](https://github.com/omarlopesino "omarlopesino (12 commits)")[![apmg-alex](https://avatars.githubusercontent.com/u/142323467?v=4)](https://github.com/apmg-alex "apmg-alex (10 commits)")[![Eduardo-Morales-Alberti](https://avatars.githubusercontent.com/u/24698482?v=4)](https://github.com/Eduardo-Morales-Alberti "Eduardo-Morales-Alberti (7 commits)")[![AliagaDev](https://avatars.githubusercontent.com/u/10268016?v=4)](https://github.com/AliagaDev "AliagaDev (2 commits)")[![Cristthian](https://avatars.githubusercontent.com/u/28946269?v=4)](https://github.com/Cristthian "Cristthian (2 commits)")

---

Tags

testingdrupalBehatlexsoft

### Embed Badge

![Health badge](/badges/lexsoft-drupal-behat-contexts/health.svg)

```
[![Health](https://phpackages.com/badges/lexsoft-drupal-behat-contexts/health.svg)](https://phpackages.com/packages/lexsoft-drupal-behat-contexts)
```

###  Alternatives

[drupal/drupal-extension

Drupal extension for Behat

21115.5M166](/packages/drupal-drupal-extension)[imbo/behat-api-extension

API extension for Behat

1092.6M9](/packages/imbo-behat-api-extension)[drevops/behat-steps

Collection of steps for Behat

27409.9k4](/packages/drevops-behat-steps)[acquia/drupal-spec-tool

A tool for specifying Drupal architecture details and generating automated tests for them

1532.7M3](/packages/acquia-drupal-spec-tool)[nuvoleweb/drupal-behat

Drupal Behat extension.

33823.5k4](/packages/nuvoleweb-drupal-behat)[drupal/tqextension

Behat extension for testing Drupal sites

1134.4k](/packages/drupal-tqextension)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
