Skip to content

Commit 8942fab

Browse files
authored
Merge pull request #89 from TurekBot/fix-alias-selector-example
Fix Selector Alias Example
2 parents 20db39f + aa366b8 commit 8942fab

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/docs/handbook/web-testing/page-element-query-language.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ and others.
9999
### Using selector aliases
100100

101101
In scenarios where elements use a consistent pattern allowing them to be easily identified,
102-
such as a `data-test-it`, or a `role` attribute, you might want to implement custom selector aliases
102+
such as a `data-testid`, or a `role` attribute, you might want to implement custom selector aliases
103103
to avoid code duplication.
104104

105105
For example, below function `byRole` helps to locate elements with
@@ -129,8 +129,8 @@ selector value using an [`Answerable<string>`](/api/core#Answerable):
129129
import { Answerable, q } from '@serenity-js/core'
130130
import { By, PageElement } from '@serenity-js/web'
131131

132-
const byTestId = (dataTestId: Answerable<string>) =>
133-
PageElement.located(By.css(q`[data-test-id="${ dataTestId }"]`))
132+
export const byTestId = (dataTestId: Answerable<string>) =>
133+
By.css(q`[data-testid="${ dataTestId }"]`)
134134
```
135135

136136
Note that the example above uses [tag function `q`](/api/core/function/q) to concatenate a static string with an [`Answerable<string>`](/api/core/#Answerable).

0 commit comments

Comments
 (0)