Web steps
Web steps work on any website, whatever it's built with. They visit pages, fill in and submit forms, follow links and read cookies and response headers. They also check JSON, XML and tables, all through the browser Mink drives. WebContext brings every one of them, and DrupalContext extends WebContext, so a FeatureContext built on either already has them all. Contexts explains which one to extend.
The steps come grouped into traits, 1 per job, such as cookies, form fields or JSON responses. The table at the end of this page lists every trait and what it covers, and each name opens the trait's page.
How a trait's page reads
The page opens with the trait's class and its links: the source, the feature file that tests it and its helpers in HELPERS.md. A description of what the trait does follows. Then, where the trait has them:
- Prerequisites: what the site has to provide before the trait's steps can run.
- Options: the settings the trait reads, with their defaults and the tags that change them for 1 scenario. Configure a trait shows where to set them.
- Steps: every step of the trait, each under its
Given,WhenorThenkeyword. Open a step to see what it does and an example you can copy into a scenario.
A few steps need a real browser, because they run the page's JavaScript, press keys or resize the window. They fail under the BrowserKit session the quick start sets up, and Browsers covers the browsers that run them.
Find a step
You can find a step in 3 ways:
- Search the site with the box at the top of the page.
- Run
vendor/bin/behat --definitions=lin your project. It lists every step your suite registers, Mink's and your own included. - Open STEPS.md, which holds these steps and the Drupal steps on 1 page. It ships with the package, so an AI coding agent in your project can read it from
vendor/.
Every web trait
| Name | Trait | Description |
|---|---|---|
| Accessibility | AccessibilityTrait | Assess accessibility of rendered pages. |
| Basic authentication | BasicAuthTrait | Keep HTTP basic authentication applied across session resets. |
| Cookies | CookieTrait | Verify and inspect browser cookies. |
| Dropzone uploads | DropzoneTrait | Simulate a real multi-file drag-and-drop gesture onto a Dropzone target. |
| Elements | ElementTrait | Interact with HTML elements using CSS selectors and DOM attributes. |
| Failure diagnostics | DiagnosticsTrait | Append on-failure diagnostics to the failure message of any failed step. |
| File downloads | FileDownloadTrait | Test file download functionality with content verification. |
| Form fields | FieldTrait | Manipulate form fields and verify widget functionality. |
| Iframes | IframeTrait | Switch between iframes and the root document. |
| JavaScript errors | JavascriptTrait | Automatically detect JavaScript errors during test execution. |
| JSON responses | JsonTrait | Assert JSON responses with path and schema checks. |
| Keyboard | KeyboardTrait | Simulate keyboard interactions in the browser. |
| Links | LinkTrait | Verify link elements with attribute and content assertions. |
| Mapped values | MappingTrait | Replace {{ Key }} tokens in step arguments and table cells. |
| Messages | MessageTrait | Assert status, error, warning and success messages rendered on the page. |
| Meta tags | MetatagTrait | Assert <meta> tags and head/SEO markup in page markup. |
| Modals | ModalTrait | Interact with and assert modals. |
| Page regions | RegionTrait | Interact with and assert against named page regions. |
| Paths | PathTrait | Navigate and verify paths with URL validation. |
| Random values | RandomTrait | Replace random-value tokens in step arguments and table cells. |
| Relative dates | DateTrait | Convert relative date expressions into timestamps or formatted dates. |
| Response headers | ResponseTrait | Verify HTTP response headers. |
| Responsive layouts | ResponsiveTrait | Test responsive layouts with viewport control. |
| REST APIs | RestTrait | Test REST APIs with lightweight steps. |
| Shell commands | CommandTrait | Run local shell commands and assert on their result. |
| Tables | TableTrait | Interact with HTML table elements and assert their content. |
| Waits | WaitTrait | Wait for a period of time or for AJAX to finish. |
| XML responses | XmlTrait | Assert XML responses with element and attribute checks. |