PHPackages                             webforge/behat-css-extension - 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. webforge/behat-css-extension

ActiveLibrary[Testing &amp; Quality](/categories/testing)

webforge/behat-css-extension
============================

Helpers for css selection in behat tests

v4.1.0(2w ago)08.5k↓49%1MITPHPPHP &gt;=7.4CI failing

Since Nov 12Pushed 2w ago1 watchersCompare

[ Source](https://github.com/webforge-labs/behat-css-extension)[ Packagist](https://packagist.org/packages/webforge/behat-css-extension)[ RSS](/packages/webforge-behat-css-extension/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (2)Dependencies (8)Versions (17)Used By (0)

Behat css Extension
===================

[](#behat-css-extension)

(not yet an extension, but usable)
It extends the mink extension to actual usuable, chained css expressions

You need:

- behat
- behat/mink-extension
- behat/mink-selenium2-driver
- symfony/css-selector
- hamcrestphp

installation
------------

[](#installation)

```
compose require --dev webforge/behat-css-extension

```

you need to install (additional to your normal behat setup):

```
"behat/behat": "^3.5",
"behat/mink-extension": "^2.3",
"behat/mink-selenium2-driver": "^1.3",

```

or (to use selenium 4)

```
behat/behat
behat/mink
friends-of-behat/mink-extension
friends-of-behat/symfony-extension
lullabot/mink-selenium2-driver

```

use those dependencies in your dev-dependencies.

docker
------

[](#docker)

```
services:
    selenium:
        image: selenium/hub:4.27
        environment:
            - TZ=Europe/Berlin

    selenium_chrome:
        image: selenium/node-chrome:4.27
        shm_size: 2gb
        volumes:
            - /dev/shm:/dev/shm
        depends_on:
            - selenium
        environment:
            - SE_EVENT_BUS_HOST=selenium
            - SE_EVENT_BUS_PUBLISH_PORT=4442
            - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
            - NODE_MAX_INSTANCES=3
            - NODE_MAX_SESSION=6
            - TZ=Europe/Berlin
            - LANG_WHICH=de
            - LANG_WHERE=DE
            - LANGUAGE=de_DE.UTF-8
            - LANG=de_DE.UTF-8
```

behat.yaml
----------

[](#behatyaml)

```
default:
    extensions:
        FriendsOfBehat\SymfonyExtension:
            kernel:
                class: \Kernel
                environment: test

        Behat\MinkExtension:
            base_url: http://web.local.testing
            sessions:
                selenium:
                    selenium2:
                        browser: chrome
                        wd_host: "selenium:4444/wd/hub"
                        capabilities:
                            extra_capabilities:
                                acceptSslCerts: true
                                acceptInsecureCerts: true
                            chrome:
                                switches: [ "window-size=1280,900", "ignore-certificate-errors", "no-sandbox" ]
                                prefs:
                                    intl:
```

usage
-----

[](#usage)

Use in your BehatFeatureContext:

```
use Behat\MinkExtension\Context\MinkContext;
use Behat\Behat\Context\Context;
use Webforge\Behat\CssUtilitiesTrait;

class MyFeatureContext extends MinkContext implements Context
{
    use CssUtilitiesTrait;

    /**
     * @Given /^I wait for the page to load$/
     */
    public function iWaitForThePageToLoad()
    {
        $this->context = $this->css('.v-dialog--active')->exists();
        $this->context('.container .headline:contains("Wähle dein Fotobuch-Format")')->waitForVisible(5000);
    }

   /**
     * @When /^I click on the position button$/
     */
    public function iClickOnThePositionButton()
    {
        $this->css('.v-btn:contains("Position")')->exists()->click();
    }

    /**
     * @Given /^I click on the undock headline icon$/
     */
    public function iClickOnTheUndockHeadlineIcon()
    {
        $this->context('.v-btn:contains("Überschrift ablösen")')->exists()->click();
    }

    /**
     * @Given /^the headline is displayed in text$/
     */
    public function theHeadlineIsDisplayedInText()
    {
        $this->css('.pb-container.headline')->waitForExist() // selector is:  .pb-container.headline
            ->css('.headline.visible')->notExists()->end() // selector is: .pb-container.headline .headline.visible
            ->css('.headline h1')->isNotVisible(); // selector is now: .pb-container.headline .headline h1
    }
}
```

- use $this-&gt;css($selector) to start from document, $selector is a valid css3 selector (supported by `symfony/css-selector`)
- set $this-&gt;context to whatever dialog/page/subarea you want to select elements
- use $this-&gt;context() to start from context
- use $this-&gt;resetContext() to reset context to document
- use wait\*, exists, isVisible, isNotVisible to make assertions against your selected element
- move down with -&gt;css() to find sub-selectors
- move with -&gt;end() back up to the chain, to the last css() call
- use all(), getElements(), get\* to retrieve elements, attributes or others an break the chain

###  Health Score

54

—

FairBetter than 96% of packages

Maintenance96

Actively maintained with recent releases

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 96.8% 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

Every ~185 days

Recently: every ~60 days

Total

16

Last Release

18d ago

Major Versions

v1.2.1 → v2.0.02020-03-11

v2.1.2 → v3.0.02022-05-27

v3.1.0 → v4.0.02025-10-20

v4.0.1 → v5.0.0-alpha2025-11-16

PHP version history (3 changes)v1.0.0PHP &gt;=7.2

v3.0.0PHP &gt;=7.4

v5.0.0-alphaPHP &gt;=8.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/bc659f3d1fe2fd98e62c9ac16965126a8b2c7f3fe7fad3b7c6c5f548c46e0c27?d=identicon)[pscheit](/maintainers/pscheit)

---

Top Contributors

[![pscheit](https://avatars.githubusercontent.com/u/488189?v=4)](https://github.com/pscheit "pscheit (30 commits)")[![violinist-bot](https://avatars.githubusercontent.com/u/27495990?v=4)](https://github.com/violinist-bot "violinist-bot (1 commits)")

---

Tags

behatcss3phptesting-tools

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/webforge-behat-css-extension/health.svg)

```
[![Health](https://phpackages.com/badges/webforge-behat-css-extension/health.svg)](https://phpackages.com/packages/webforge-behat-css-extension)
```

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[drupal/drupal-extension

Drupal extension for Behat

22215.7M173](/packages/drupal-drupal-extension)[drupal/core-dev

require-dev dependencies from drupal/drupal; use in addition to drupal/core-recommended to run tests from drupal/core.

2022.6M343](/packages/drupal-core-dev)[sinnbeck/laravel-dom-assertions

107301.8k9](/packages/sinnbeck-laravel-dom-assertions)[zenstruck/browser

A fluent interface for your Symfony functional tests.

2262.6M43](/packages/zenstruck-browser)[spatie/laravel-visit

Quickly visit any route of your Laravel app

16016.2k](/packages/spatie-laravel-visit)

PHPackages © 2026

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