To get 'n' number of random values from the below array whenever i execute the test script. How i can i achieve this into Karate in a feature file.
[ "2972029540", "2972033041", "2972030914", "2972028446", "2972030851", "2972026534", "2972029484" ]
Here you go:
* def random = function(max){ return Math.floor(Math.random() * max) + 1 }
* def data = [ "2972029540", "2972033041", "2972030914", "2972028446", "2972030851", "2972026534", "2972029484" ]
* def count = random(data.length)
* print 'random count is', count
* def temp = data.slice(0, count)
* print temp
Read this for more info: https://stackoverflow.com/a/53975071/143475