I create a variable in my yml artillery file which I can then access from my Playwright function.
variables:
redirectUrl: "foo"
I then dynamically assign a url I get from an api call to this variable.
- post:
url: "/ipgw/wrapper/v1/customer-token/{{guid}}/pay"
form:
amount: 10
reference: "{{uuid}}"
return_url: "https://www.google.com/"
capture:
- json: "$.url"
as: "redirectUrl"
However I cannot figure out how to dynamically set that redirectUrl variable by using the response from an api call I make just before I call that function.
The below function picks up on the placeholder value of 'foo' and not the value I dynamically assign that I get from the api response.
async function ipgHostedPages(page, context) {
await page.goto(context.vars['redirectUrl']);
await page.getByPlaceholder('CVV').fill('***');
await page.getByRole('button', { name: 'Pay' }).click();
await page.getByLabel('Password:').fill('***');
await page.getByRole('button', { name: 'Submit' }).click();
await page.getByText('Redirect Now').click();
}