File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed
docs/sources/k6/next/javascript-api/k6-browser/locator Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ title : ' last()'
3
+ description : ' Browser module: locator.last method'
4
+ ---
5
+
6
+ # last()
7
+
8
+ Returns locator to the last matching element.
9
+
10
+ ### Returns
11
+
12
+ | Type | Description |
13
+ | -------------------------------------------------------------------------------------- | -------------------------------------------------------- |
14
+ | [ Locator] ( https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/locator/ ) | The last element ` Locator ` associated with the selector. |
15
+
16
+ ### Example
17
+
18
+ {{< code >}}
19
+
20
+ ``` javascript
21
+ import { expect } from ' https://jslib.k6.io/k6-testing/0.4.0/index.js' ;
22
+ import { browser } from ' k6/browser' ;
23
+
24
+ export const options = {
25
+ scenarios: {
26
+ ui: {
27
+ executor: ' shared-iterations' ,
28
+ options: {
29
+ browser: {
30
+ type: ' chromium' ,
31
+ },
32
+ },
33
+ },
34
+ },
35
+ };
36
+
37
+ export default async function () {
38
+ const page = await browser .newPage ();
39
+ await page .goto (' https://quickpizza.grafana.com' );
40
+
41
+ await expect (await page .locator (' p' ).last ()).toContainText (' Contribute to QuickPizza' );
42
+
43
+ await page .close ();
44
+ }
45
+ ```
46
+
47
+ {{< /code >}}
You can’t perform that action at this time.
0 commit comments