-
Notifications
You must be signed in to change notification settings - Fork 174
[synthetics] Document the request parameter
#2071
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
This pull request does not have a backport label. Could you fix it @colleenmcginnis? 🙏
|
|
A documentation preview will be available soon: |
I agree, it seems a little odd for it to go in the params and secrets section as it's out of context for the rest of that page. I think it might be better on the write a test page. I think the reference to |
request parameterrequest parameter
colleenmcginnis
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready for review -- a few questions/comments below.
andrewvc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the new docs but found some bugs!
paulb-elastic
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree that the example maybe does look a bit complex as there are other things in there about decoding that aren’t necessarily related to the request.
If the purpose of the docs is to show how a request can be made and they used in the script (irrespective of having an example in our demos are at some point), maybe a simpler example would be useful.
I’ll defer to @andrewvc’s suggestions here, but here is an example I put together for something recently (it makes a request for a quote of the day, then uses this in a Google search):
step("Google Page", async () => {
// HTTP request for the quote
const resp = await request.get("http://quotes.stormconsultancy.co.uk/random.json");
// parse the response
quote = JSON.parse((await resp.body()).toString()).quote;
// visit Google with the quote
await page.goto('https://www.google.com?q=' + quote);
});
(Maybe this is too simple and not a realistic enough scenario, so feel free to use it or not)
I'll LGTM and defer to Andrew's suggestion regarding the specifics of the example.
| // The Elastic Synthetics `request` parameter is similar to Playwright's | ||
| // https://playwright.dev/docs/api/class-apirequestcontext[`APIRequestContext`], but | ||
| // it comes built into Elastic Synthetics and doesn't have to be imported separately. | ||
| // This reduces the code needed and allows you to make API requests in inline journeys. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to mention how this is different from the other request objects that is exposed by Playwright.
@vigneshshanmugam is this what you had in mind? Are there other differences?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking something along the lines of
- Top level
requestobject exposed by synthetics have its own isolated cookie storage and its different from thecontext.requestandpage.requestas they shares cookie storage with the corresponding BrowserContext. - If you want to control the creation of this request object - https://playwright.dev/docs/api/class-apirequest#api-request-new-context, you can do so by passing options via
--playwright-optionsorsynthetics.config.tsfile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, Thanks @colleenmcginnis
vigneshshanmugam
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I'm moving forward with other approvals -- I can make additional changes as needed in a follow-up PR.
* 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 (cherry picked from commit ed30777)
* 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 (cherry picked from commit ed30777) Co-authored-by: Colleen McGinnis <[email protected]>

Closes #2049
Overview
Adds documentation on the new
requestparameter that allows users to make API requests independently of the browser interactions. For example, to get authentication credentials or tokens in service of a browser-based test.For the reviewer
@paulb-elastic @andrewvc:
journey?To do
requestparameter fits into the current docs