Escaping HTML Tag Brackets & Correlation using Regex

Hi Everyoone,

I am new to K6 and trying my handson with a script using this tool

I came across multiple dynamic radio buttons where I’m trying to save the values in an array for it but since the name tag contains square brackets (name=“challenger[order_selected]”) in it it doesnt seem to recognise it

I have tried using double and single backslash to escape them. Not sure on what I’m doing wrong
Could someone help me on this please. Thanks in advance
(Or if there are any samples to capture/correlate values using regular expressions, couldnt find any on the K6 Documentation)

**Code :**
  vars["C_Radio_List"] = response
      .html()
      .find("input[name=challenger\[order_selected\]]")
      .attr("value")
    .toArray()
    .forEach(function (item) {
      arr1[i] = item.text()
      console.log("Radio Button Value:"+item.text());
      i++
    });
**Error:**
ERRO[0021] TypeError: Cannot read property 'toArray' of undefined or null
**Value to Capture**
value="N1h4MFpVcTJqTkNETXpaWDh2QUYyZz09LS1xR2k0b0s1OWtvU3hpbG12Z2JnUEdnPT0=--b9d6e407d77b86ddf8814801774c53c4357cf044"
Sample HTML Response containing radio button
<div class="input radio_buttons optional challenger_order_selected"><span class="radio"><input class="radio_buttons optional" id="challenger_order_selected_n1h4mfpvctjqtknetxpawdh2quyyzz09ls1xr2k0b0s1owtvu3hpbg12z2jnuednpt0--b9d6e407d77b86ddf8814801774c53c4357cf044" name="challenger[order_selected]" type="radio" value="N1h4MFpVcTJqTkNETXpaWDh2QUYyZz09LS1xR2k0b0s1OWtvU3hpbG12Z2JnUEdnPT0=--b9d6e407d77b86ddf8814801774c53c4357cf044" /><label class="collection_radio_buttons" for="challenger_order_selected_n1h4mfpvctjqtknetxpawdh2quyyzz09ls1xr2k0b0s1owtvu3hpbg12z2jnuednpt0--b9d6e407d77b86ddf8814801774c53c4357cf044">22</label></span></div>

Hi @amanikoth, welcome to the forum :tada: .

You need to double escape as in input[name=challenger\\[order_selected\\]].

Hope this helps you and for future reference while we don’t use jquery the language is supposed to act exactly the same, so anything that should work with jquery should do inside k6 as well.

Hi @mstoykov ,

Thank you for your response

Regards,
Amrish