This step prints every currently registered CSS selector to the test runner's console output. It is a synchronous debug utility - it does not interact with the page or assert anything. Each entry is printed on its own line in the format "name": selector-string, preceded by a --- CSS Selectors --- header.
Use this step when a position or visibility assertion fails with an "unknown selector" error and you are unsure which names are currently registered. Place it immediately before the failing step to inspect the registry state at that point in the scenario. The step accepts any Gherkin keyword (Given, When, Then, And, But) and both I and we pronouns, so it can sit naturally anywhere in a scenario without disrupting Gherkin grammar.
Accepted phrasings
Then I print css selectors
Then we print css selectors
When I print css selectors
When we print css selectors
Given I print css selectors
And I print css selectors
But I print css selectors
Then print css selectors
Examples
Then I print css selectors
When we print css selectors
And I print css selectors
Given print css selectors
In a real scenario
Scenario: Debug registered selectors before a layout assertion
Given I navigate to "https://example.org/"
And I define css selectors:
| header | header.site-header |
| nav | nav.primary-nav |
| content | .main-content |
| footer | footer.site-footer |
When I add "logo" selector for ".site-logo" css selector
Then I print css selectors
And I see header above nav, content and footer