ERRO[0008] no form found for selector ‘form’ in response
at reflect.methodValueCall (native)
at file:///C:/Program%20Files/k6/orig_k6.txt:75:18(12)
at go.k6.io/k6/js/modules/k6.(*K6).Group-fm (native)
at file:///C:/Program%20Files/k6/orig_k6.txt:65:2(14)
Hello! This will be tricky to answer without being able to see what kind of responses you are working with; the error is telling you that there was no <form> element in a response.body that your script is checking through.
The code you’ve shared isn’t doing any kind of extracting of forms from responses though - is there more code later on, perhaps?
Are you sure it is just this request that has changed? The only real way to know for sure would be to create a recording (e.g. using our Browser Recorder, or a web proxy) and comparing that to what was in the previously-working script, making changes as necessary to bring them in line.
Thanks for the response. The code for the rest of the script is the same in both instances. It is only the login page URL definition that has changed. It is possible that the mechanics of the page in the new version vs the old version are sufficiently different for the script to fail.
The bulk of the rest of the script looks like this:
Been digging into the new system and the mechanics of what it does are very different compared to the old version. The login page is now sending a large block of JSON instead of just a couple of lines worth of form data.
I guess I need to work out how to replace that "group(‘submit form’, function () " code block with the necessary bits to send the JSON data.
This is the payload that needs to be sent now. The value of the Id data changes with each login so I’m not sure if this can be scripted. How would I go about submitting this?
That looks like a JWT (Bearer token). These are typically received from some earlier request’s response.body. The process of handling these kinds of dynamic IDs is called Data Correlation and it is something that one frequently encounters when working with k6 scripts.
I’d recommend reading the article and using the aforementioned Browser Recorder and web proxy to figure out where the value is coming from. The easiest way to extract it will probably be to use findBetween as it works regardless of Content-Type (but you might be dealing with JSON, in which case you can use response.json() to get the value with dot notation).