Skip to content

Commit 034463c

Browse files
Update mentions of Playwright (#2051)
* Update mentions of Playwright * Playwright methods * Add skip code blocks * Ankur's feedback * Apply to v1.2.x
1 parent 55dbad7 commit 034463c

File tree

14 files changed

+34
-52
lines changed

14 files changed

+34
-52
lines changed

docs/sources/k6/next/javascript-api/k6-browser/_index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ weight: 02
88

99
# browser
1010

11-
The browser module APIs aim for rough compatibility with the [Playwright API for NodeJS](https://playwright.dev/docs/api/class-playwright).
11+
The browser module APIs are inspired by Playwright and other frontend testing frameworks.
1212

13-
Note that because k6 does not run in NodeJS, the browser module APIs will slightly differ from their Playwright counterparts.
14-
15-
You can find examples of using [the browser module API](#browser-module-api) in our [getting started guide](https://grafana.com/docs/k6/<K6_VERSION>/using-k6-browser).
13+
You can find examples of using [the browser module API](#browser-module-api) in the [getting started guide](https://grafana.com/docs/k6/<K6_VERSION>/using-k6-browser).
1614

1715
{{< admonition type="note" >}}
1816

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 'ConsoleMessage'
3-
slug: 'consolemessage'
43
description: 'Browser module: ConsoleMessage Class'
54
weight: 03
65
---
@@ -11,9 +10,9 @@ weight: 03
1110

1211
## Supported APIs
1312

14-
| Method | Playwright Relevant Distinctions |
15-
| --------------------------------------------------------------------------------------------------------------- | -------------------------------- |
16-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-args" target="_blank" >args()</a> | - |
17-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-page" target="_blank" >page()</a> | - |
18-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-text" target="_blank" >text()</a> | - |
19-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-type" target="_blank" >type()</a> | - |
13+
| Method | Description |
14+
| ------ | ---------------------------------------------------------------- |
15+
| args() | List of arguments passed to a `console` function call. |
16+
| page() | The page that produced this console message. |
17+
| text() | The text of the console message. |
18+
| type() | The type of the console message. For example: `log`, or `debug`. |

docs/sources/k6/next/javascript-api/k6-browser/request/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The request that the browser performs can be retrieved from the [Response](https
1212

1313
## Supported APIs
1414

15-
| Method | Playwright Relevant Distinctions |
15+
| Method | Description |
1616
| --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
1717
| [allHeaders()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/allheaders) {{< docs/bwipt id="965" >}} | Returns an object of headers associated to the request including headers added by the browser. |
1818
| [frame()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/frame) | The [Frame](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/frame/) that initiated the request. |
@@ -25,7 +25,7 @@ The request that the browser performs can be retrieved from the [Response](https
2525
| [postDataBuffer()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/postdatabuffer) | Request's post body in a binary form, if any. |
2626
| [resourceType()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/resourcetype) | Contains the request's resource type as it was perceived by the rendering engine. |
2727
| [response()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/response) | Returns the matching [Response](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/response) object. |
28-
| [size()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/size) | Unlike Playwright, this method returns an object containing the sizes of request headers and body. |
28+
| [size()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/size) | Returns an object containing the size of the request headers and body. |
2929
| [timing()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/timing) | Returns resource timing information for given request. |
3030
| [url()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/url) | URL of the request. |
3131

docs/sources/k6/next/shared/javascript-api/jslib.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ title: javascript-api/jslib
1111
| [k6chaijs](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/k6chaijs) | BDD assertion style |
1212
| [http-instrumentation-pyroscope](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-pyroscope) | Library to instrument k6/http to send baggage headers for pyroscope to read back |
1313
| [http-instrumentation-tempo](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/http-instrumentation-tempo) | Library to instrument k6/http to send tracing data |
14-
| [testing](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing) | Advanced assertion library with Playwright-compatible API for protocol and browser testing |
14+
| [testing](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/testing) | Advanced assertion library with Playwright-inspired API for protocol and browser testing |
1515
| [utils](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/jslib/utils) | Small utility functions useful in every day load testing |

docs/sources/k6/next/using-k6-browser/_index.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ weight: 300
1010

1111
The browser module brings browser automation and end-to-end web testing to k6 while supporting core k6 features. It adds browser-level APIs to interact with browsers and collect frontend performance metrics as part of your k6 tests.
1212

13-
This module aims to provide rough compatibility with the Playwright API, so you don’t need to learn a completely new API.
14-
1513
{{< admonition type="note" >}}
1614

1715
To work with the browser module, make sure you are using the latest [k6 version](https://github.com/grafana/k6/releases), and install a Chromium-based browser on your machine (such as [Google Chrome](https://www.google.com/chrome/)).

docs/sources/k6/next/using-k6-browser/how-to-write-browser-tests/asynchronous-operations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ This avoids the use of `Promise.all` which can be confusing to work with, and in
116116
The browser module uses asynchronous APIs that require `await` for several reasons:
117117

118118
1. JavaScript is single-threaded with a single event loop. Asynchronous APIs prevent blocking the thread and event loop with long-running or I/O-based tasks.
119-
1. Consistency with [Playwright](https://playwright.dev/), a popular browser automation library.
119+
1. Consistency with [Playwright](https://playwright.dev/) and other frontend testing frameworks.
120120
1. Alignment with how developers expect to work with modern JavaScript APIs.
121121

122122
For example:

docs/sources/k6/next/using-k6-browser/recommended-practices/page-object-model-pattern.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ weight: 02
88

99
# Page object model
1010

11-
When working with large test suites, a popular design pattern to improve your codes maintainability and readability is the [page object model](https://martinfowler.com/bliki/PageObject.html).
11+
When working with large test suites, a popular design pattern to improve your code's maintainability and readability is the [page object model](https://martinfowler.com/bliki/PageObject.html).
1212

13-
A page object commonly represents an HTML page or significant elements/components within a page, such as a header or a footer. It is a form of encapsulation that hides the details of the UI structure from other places, such as your test files. Through page object models, any changes you need to make on a specific page or element within a page are constrained into a single place, resulting in ease of maintenance and avoiding code duplication.
13+
A page object commonly represents an HTML page or significant elements/components within a page, such as a header or a footer. It's a form of encapsulation that hides the details of the UI structure from other places, such as your test files. Through page object models, any changes you need to make on a specific page or element within a page are constrained into a single place, resulting in ease of maintenance and avoiding code duplication.
1414

15-
Since k6 browser aims to provide rough compatibility with the Playwright API, you can leverage any existing page objects you have and easily re-use them with your k6 browser tests.
15+
Since k6 browser is inspired by Playwright, you can leverage any existing page objects you have and re-use them with your k6 browser tests.
1616

1717
## Implementation
1818

@@ -28,7 +28,7 @@ The `homepage.js` class also contains different methods for:
2828

2929
When locators need to be updated or other specific changes related to the homepage are made, you only need to update the `homepage.js` class.
3030

31-
{{< code >}}
31+
<!-- md-k6:skip -->
3232

3333
```javascript
3434
import { bookingData } from '../data/booking-data.js';
@@ -66,11 +66,9 @@ export class Homepage {
6666
}
6767
```
6868

69-
{{< /code >}}
70-
7169
You can import the `Homepage` class within your test class and invoke the methods you need. This makes the code easier to understand and enforces the separation between your test and business logic.
7270

73-
{{< code >}}
71+
<!-- md-k6:skip -->
7472

7573
```javascript
7674
import { browser } from 'k6/browser';
@@ -93,5 +91,3 @@ export default async function () {
9391
await page.close();
9492
}
9593
```
96-
97-
{{< /code >}}

docs/sources/k6/v1.2.x/javascript-api/k6-browser/_index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ weight: 02
88

99
# browser
1010

11-
The browser module APIs aim for rough compatibility with the [Playwright API for NodeJS](https://playwright.dev/docs/api/class-playwright).
11+
The browser module APIs are inspired by Playwright and other frontend testing frameworks.
1212

13-
Note that because k6 does not run in NodeJS, the browser module APIs will slightly differ from their Playwright counterparts.
14-
15-
You can find examples of using [the browser module API](#browser-module-api) in our [getting started guide](https://grafana.com/docs/k6/<K6_VERSION>/using-k6-browser).
13+
You can find examples of using [the browser module API](#browser-module-api) in the [getting started guide](https://grafana.com/docs/k6/<K6_VERSION>/using-k6-browser).
1614

1715
{{< admonition type="note" >}}
1816

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: 'ConsoleMessage'
3-
slug: 'consolemessage'
43
description: 'Browser module: ConsoleMessage Class'
54
weight: 03
65
---
@@ -11,9 +10,9 @@ weight: 03
1110

1211
## Supported APIs
1312

14-
| Method | Playwright Relevant Distinctions |
15-
| --------------------------------------------------------------------------------------------------------------- | -------------------------------- |
16-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-args" target="_blank" >args()</a> | - |
17-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-page" target="_blank" >page()</a> | - |
18-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-text" target="_blank" >text()</a> | - |
19-
| <a href="https://playwright.dev/docs/api/class-consolemessage#console-message-type" target="_blank" >type()</a> | - |
13+
| Method | Description |
14+
| ------ | ---------------------------------------------------------------- |
15+
| args() | List of arguments passed to a `console` function call. |
16+
| page() | The page that produced this console message. |
17+
| text() | The text of the console message. |
18+
| type() | The type of the console message. For example: `log`, or `debug`. |

docs/sources/k6/v1.2.x/javascript-api/k6-browser/request/_index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The request that the browser performs can be retrieved from the [Response](https
1212

1313
## Supported APIs
1414

15-
| Method | Playwright Relevant Distinctions |
15+
| Method | Description |
1616
| --------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- |
1717
| [allHeaders()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/allheaders) {{< docs/bwipt id="965" >}} | Returns an object of headers associated to the request including headers added by the browser. |
1818
| [frame()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/frame) | The [Frame](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/frame/) that initiated the request. |
@@ -25,7 +25,7 @@ The request that the browser performs can be retrieved from the [Response](https
2525
| [postDataBuffer()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/postdatabuffer) | Request's post body in a binary form, if any. |
2626
| [resourceType()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/resourcetype) | Contains the request's resource type as it was perceived by the rendering engine. |
2727
| [response()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/response) | Returns the matching [Response](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/response) object. |
28-
| [size()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/size) | Unlike Playwright, this method returns an object containing the sizes of request headers and body. |
28+
| [size()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/size) | Returns an object containing the size of the request headers and body. |
2929
| [timing()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/timing) | Returns resource timing information for given request. |
3030
| [url()](https://grafana.com/docs/k6/<K6_VERSION>/javascript-api/k6-browser/request/url) | URL of the request. |
3131

0 commit comments

Comments
 (0)