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
[synthetics] Document the request parameter (#2071)
* initial approach
* move from params/secrets to write a test
* remove detailed examples
* add info on how synthetics request is different than playwright request
* final clean up
@@ -176,6 +179,37 @@ For more details on getting started with the Synthetics Recorder, see <<syntheti
176
179
177
180
image::images/synthetics-create-test-script-recorder.png[Elastic Synthetics Recorder after recording a journey and clicking Export]
178
181
182
+
[discrete]
183
+
[[synthetics-request-param]]
184
+
== Make API requests
185
+
186
+
You can use the `request` parameter to make API requests independently of browser interactions.
187
+
For example, you could retrieve a token from an HTTP endpoint and use it in a subsequent webpage request.
188
+
189
+
[source,js]
190
+
----
191
+
step('make an API request', async () => {
192
+
const response = await request.get(params.url);
193
+
// Do something with the response
194
+
})
195
+
----
196
+
197
+
The Elastic Synthetics `request` parameter is similar to https://playwright.dev/docs/api/class-apirequestcontext[other request objects that are exposed by Playwright]
198
+
with a few key differences:
199
+
200
+
* The Elastic Synthetics `request` parameter comes built into the library so it doesn't
201
+
have to be imported separately, which reduces the lines of code needed and allows you to
202
+
make API requests in inline journeys.
203
+
* The top level `request` object exposed by Elastic Synthetics has its own isolated cookie storage
204
+
unlike Playwright's `context.request` and `page.request`, which share cookie storage
205
+
with the corresponding https://playwright.dev/docs/api/class-browsercontext[`BrowserContext`].
206
+
* If you want to control the creation of the `request` object, you can do so by passing options
207
+
via <<elastic-synthetics-command, `--playwright-options`>> or in the
Copy file name to clipboardExpand all lines: docs/en/observability/synthetics-params-secrets.asciidoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ These options are discussed in detail in the sections below.
53
53
[discrete]
54
54
[[synthetics-dynamic-configs]]
55
55
// lint ignore params
56
-
== Using a config file to set params
56
+
== Use a config file to set params
57
57
58
58
Use a `synthetics.config.js` or `synthetics.config.ts` file to define variables your tests always need to be defined.
59
59
This file should be placed in the root of your synthetics project.
@@ -79,7 +79,7 @@ Note that we use the `env` variable in the above example, which corresponds to t
79
79
[discrete]
80
80
[[synthetics-cli-params]]
81
81
// lint ignore params
82
-
== Using CLI arguments to set params
82
+
== Use CLI arguments to set params
83
83
84
84
To set parameters when running `elastic-synthetics` on the command line, use the `--params` or `-p` flag to the `elastic-synthetics` program. The provided map is merged over any existing variables defined in the `synthetics.config.{js,ts}` file.
85
85
@@ -88,7 +88,7 @@ To override the `url` parameter, you would run: `elastic-synthetics . --params '
88
88
[discrete]
89
89
[[synthetics-hb-params]]
90
90
// lint ignore params
91
-
== Using {heartbeat} options to set params
91
+
== Use {heartbeat} options to set params
92
92
93
93
When running via {heartbeat} use the `params` option to set additional parameters, passed through the `--params` flag
94
94
mentioned above and have their values merged over any default values. In the example below we run the `todos` app, overriding the `url`
0 commit comments