Hello Everyone,
I have recorded a test script via k6 browser recorder. In the recorded script there are many http calls get recorded at backend where dynamic infatoken is being generated which is unique for each flow. Now i have made the script the way so that it can read the dynamic value in each execution of the test script and the code looks like this -
const res_2 = http.get('https://k6.io/')
console.log(res_2)
const infatoken_1 = findBetween(res_2.body, '\r\n\t\t\t\tinfaToken: ', ',\r\n\t\t\t\tlocale');
console.log('infatoken is' + infatoken_1)
Here it is printing the correct infatoken in logs. But when i am trying to pass it in http request, This request is getting failed.
This is how i am trying to pass the infatoken in http request -
response = http.get(
'https://k6.io/='+infatoken_1,
{
headers: {
accept: '*/*',
'x-requested-with': 'XMLHttpRequest',
infatoken: infatoken_1,
'sec-ch-ua': '"Not.A/Brand";v="8", "Chromium";v="114", "Microsoft Edge";v="114"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
},
}
)
const isCheckPassed = check(response, { 'Check response status is 200': (res) => res.status === 200, });
if (!isCheckPassed) {
console.log('Check failed!');
console.log('Response body:', response.body);
check(response,
{ 'Request 6': response => response.status.toString() === '200' })
}
Here âRequest 6â check is failing. And showing error- {âerrorCodeâ:âinfa.core.FORBIDDENâ,âdescriptionâ:âRequest forbidden. Please contact your administrator.â}
Does anyone have any idea about it. Please help to resolve this issue.
Thanks in Advance!