Hello,
I'm trying to parse multiline field data from an x-ray test, but with no success. Data column is filled with following pattern for one test step :
req1
req2
req3
I tried to use split / exec / match on the content of the data field with endline separator, but I didn't manage to loop over array in order to retrieve details separatly.
#{for i=JQLIssuesCount|clause= issuetype = Test AND key = EVAL-218 }
#{for r=JQLIssues[i].TestStepsCount}
${set(tab, %{‘${escape:JQLIssues[i].TestSteps[r].Data}’.match(/[^\r\n]+/g)})}
// What is the relevant way to loop over ${tab} ?
#{end}
#{end}
Is there a way to loop over a split array and display content individually ?
Thanks
Hi @Tomy
I haven't fully understood what you want to do, however here are some insights that might help.
First, in Xporter, the Javascript code is run embedded under the %{....}, and it does not affect other Javascript code. When there is a %{....} is like calling a subroutine that returns an output.
However it is still possible to make some interesting code, like the one below:
${set(tab, %{var final=""; var steps='${escape:JQLIssues[i].TestSteps[r].Data}'.split('\n'); for (var x=0; i < steps.length; x++) final=final.concat('\t', steps[x]); final})}
In this Javascript it splits the information of Data into an array, then it iterates over the array to build a string of values separeted by tabs, and it returns this output string. Please note that the output must be a simple datatype, like a string or a number.
After, you can add another Javascript line to process the Xporter variable ${tab}. However, and again, it would be processed in a subroutine approach, so it is not possible to iterate over the variable ${tab} like you do for the TestSteps (or other Xray information).
I hope this helps.
Thank you.
Kind regards,
Rogério Paiva [Xray Support Team]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.