You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/docs/handbook/web-testing/page-element-query-language.md
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ and **reducing test maintenance costs** across your organisation.
12
12
13
13
Serenity/JS Page Element Query Language uses **3 simple, composable abstractions** based on Screenplay [questions](/handbook/design/screenplay-pattern/#questions)
14
14
that help you identify and interact with web elements of interest:
15
+
15
16
-**[`PageElement`](/api/web/class/PageElement)** - models a **single web element**,
16
17
-**[`PageElements`](/api/web/class/PageElements)** - models a **collection of web elements**,
17
18
-**[`By`](/api/web/class/By)** - represents **portable locators** used by your browser to identify web elements of interest.
@@ -60,6 +61,7 @@ export const basketTotal = () => // <- Function representing a do
60
61
```
61
62
62
63
To define a page element:
64
+
63
65
- Create a [function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions) named after the **domain concept** represented by the UI widget, such as `basketTotal`.
64
66
- Make the function return a [`PageElement`](/api/web/class/PageElement#located), configured to locate the element using one of the built-in [`By` selectors](/api/web/class/By).
65
67
- Give your page element a **human-readable description** to be used when [reporting interactions](/handbook/reporting/) with the element.
@@ -310,6 +312,7 @@ To help you understand how to use this abstraction, remember the shopping basket
310
312
311
313
Similarly to how you model a [single page element](/handbook/web-testing/page-element-query-language/#working-with-individual-page-elements),
312
314
to model a **collection of page elements**:
315
+
313
316
- Create a function that captures the name of the concept they represent, like `basketItems`.
314
317
- Make the function return a [PageElements](/api/web/class/PageElements/#located) object.
315
318
- Define a custom description to be used for reporting purposes.
@@ -597,6 +600,7 @@ you might want to fetch a table row, perform some transformation on each cell,
597
600
then return the result as a JSON object so that it's easier to work with.
598
601
599
602
An equivalent of doing that in our example would be to:
603
+
600
604
- retrieve the name and price of each basket item,
601
605
- clean up the data,
602
606
- transform it into a JSON object,
@@ -677,6 +681,7 @@ While Serenity/JS [expectations](/api/core/class/Expectation) are most commonly
677
681
when used with the [`PageElements#where`](/api/web/class/PageElements#where) API they offer a great and reusable alternative to complex CSS selectors and XPath expressions.
678
682
679
683
In this section, I'll show you how to:
684
+
680
685
- query page elements to find those that meet your expectations,
681
686
- find an interactive element based on some property of its sibling,
682
687
- iterate over selected elements to perform a common task.
0 commit comments