Built-in words
- Finding
-
Roles
Roles with no name
Field, Label
Text
Placeholder
Alt
Title
TestId
Containing
Within, In
- Doing
-
Click
Double-click
Hover
Focus
Check
Uncheck
Clear
Fill
Type
Select
Press
Visit
Reload
Back
Render
- Checking
-
See
Visible
Hidden
Checked
Enabled
Disabled
Focused
Empty
Value
Read
Contain
Not
At
Titled
- Lists
-
Count
Each, Every
No, None
- Steps
-
Given
When
Then
And, But
*
- Other
-
I
Print
Finding
Roles
Alertdialog, Application, Banner, Button, Cell, Checkbox, Columnheader, Combobox, Complementary, Contentinfo, Dialog, Directory, Document, Feed, Figure, Form, Grid, Gridcell, Group, Heading, Img, Link, List, Listbox, Main, Math, Meter, Menu, Menubar, Menuitem, Menuitemcheckbox, Menuitemradio, Navigation, Option, Progressbar, Radio, Radiogroup, Region, Row, Rowgroup, Rowheader, Scrollbar, Search, Searchbox, Separator, Slider, Spinbutton, Switch, Tab, Table, Tablist, Tabpanel, Textbox, Toolbar, Tooltip, Tree, Treegrid, Treeitem
Finds an element by its ARIA role and accessible name, which must match exactly.
When I Click the Button "Sign in"
Then I should See the Heading "Welcome back"
Then the Dialog should be Visible
Roles with no name
Alert, Article, Blockquote, Caption, Code, Definition, Deletion, Emphasis, Generic, Insertion, Listitem, Log, Marquee, Note, Paragraph, Presentation, Status, Strong, Subscript, Superscript, Term, Time, Timer
Finds an element by its ARIA role and the text inside it. These roles aren't named by their content.
When I Click the Button "Destroy" Within the Listitem Containing "feed the cat"
Then the Alert Containing "Saved" should be Visible
Field, Label
Finds a form control by its label.
When I Fill the Field "Email" with "will@example.com"
When I Check the Label "Remember me"
Text
Finds an element by its text.
When I Click the Text "Forgot your password?"
Placeholder
Finds a form control by its placeholder.
When I Fill the Placeholder "Search" with "kale"
Alt
Finds an image by its alt text.
Then I should See the Alt "Company logo"
Title
Finds an element by its title.
When I Hover the Title "Settings"
TestId
Finds an element by its test id. A last resort: it stands out in review.
When I Click the TestId "chart-bar-3"
Containing
Matches part of a name or text, ignoring case, or an element with another inside it.
When I Click the Button "Remove" Within the Row Containing "Kale"
Then I should See the Row Containing the Button "Undo"
Within, In
Looks inside another element.
When I Click the Link "Help" Within the Navigation
When I Click the Button "Close" In the Dialog
Doing
Click
Clicks an element.
When I Click the Button "Sign in"
Double-click
Double-clicks an element.
When I Double-click the Text "buy milk"
Hover
Moves the mouse over an element.
When I Hover the Button "Share"
Focus
Focuses an element.
When I Focus the Field "Email"
Check
Checks a checkbox or radio button.
When I Check the Checkbox "Terms"
Uncheck
Unchecks a checkbox.
When I Uncheck the Checkbox "Newsletter"
Clear
Empties a field.
When I Clear the Field "Search"
Fill
Fills a field, replacing what was in it. Given a table, fills each field by its label.
When I Fill the Field "Email" with "will@example.com"
When I Fill "hunter2" into the Field "Password"
When I Fill in the form:
| Email | will@example.com |
| Password | hunter2 |
Type
Types into a field one key at a time, as a person would.
When I Type "kale" into the Field "Search"
Select
Chooses an option in a select box.
When I Select "Blue" in the Combobox "Colour"
Press
Presses a key, on an element or on the page.
When I Press "Enter"
When I Press "Escape" in the Dialog
Visit
Only in Playwright's files
Goes to a path on the app, or a URL.
Given I Visit "/"
Reload
Only in Playwright's files
Reloads the page.
When I Reload the page
Back
Only in Playwright's files
Goes back, as the browser's back button does.
When I go Back
Render
Only in Testing Library's files
Renders what the test's gpp template has in a ${…}, like a React element.
Given I Render ${<Editor title="" />}
Checking
See
Checks an element is visible, or some text anywhere on the page.
Then I should See the Heading "Welcome back"
Then I should See "Saved"
Visible
Checks an element is visible.
Then the Dialog "Cookies" should be Visible
Hidden
Checks an element is hidden, or not there.
Then the Dialog "Cookies" should be Hidden
Checked
Checks a checkbox or radio button is checked.
Then the Checkbox "Terms" should be Checked
Enabled
Checks an element is enabled.
Then the Button "Save" should be Enabled
Disabled
Checks an element is disabled.
Then the Button "Save" should be Disabled
Focused
Checks an element has focus.
Then the Field "Email" should be Focused
Empty
Checks an element has no text, or a field no value.
Then the Field "Search" should be Empty
Value
Checks a field's value.
Then the Field "Email" should have the Value "will@example.com"
Read
Checks an element's whole text. Given a table, checks what everything found reads, in order.
Then the Status should Read "2 items left"
Then the Listitem should Read:
| buy some cheese |
| feed the cat |
Contain
Checks part of an element's text.
Then the Alert should Contain "saved"
Not
Turns a check around.
Then I should Not See the Button "Delete"
Then the Checkbox "Terms" should Not be Checked
At
Only in Playwright's files
Checks the page's path, or its whole URL.
Then I should be At "/dashboard"
Titled
Only in Playwright's files
Checks the page's title.
Then the page should be Titled "Dashboard"
Lists
Count
Checks how many elements a query finds.
Then I should Count 3 Row Within the Table
Each, Every
Checks every element a query finds. Fails if it finds none.
Then Each Checkbox "Bought" should be Checked
No, None
Checks no element a query finds passes. Passes if it finds none.
Then No Checkbox "Bought" should be Checked
Steps
Given
Starts a step that sets the scene.
Given I Check the Checkbox "Remember me"
When
Starts a step that does something.
When I Click the Button "Add"
Then
Starts a step that checks something.
Then I should See "Added"
And, But
Starts a step like the one above it. A scenario can't start with one.
Then I should See "Added"
And I should Not See "Empty"
*
Starts a step like the one above it, or, first, a step of no kind.
* I Click the Button "Add"
Other
I
Does nothing, so a step can read as a sentence.
When I Click the Button "Add"
Print
Prints a value, for debugging.
When I Print the Button "Save"