Reputation: 92
I have written a JavaScript function but i'm unable to call it in the 'Then' statement of my request. I need the syntax to call a JavaScript function in the same
Background:
* def randomPhoneString = function(list) { var rand = Math.random(); Math.floor(rand * 100000000);}
Scenario: Get list
Given path '/example/test'
When method get
Then status 200
Then def resp = response.list
Then def List = randomPhoneString(resp)
Not a great example but it would be a usecase like this. The error I'm getting is : javascript evaluation failed: randomPhoneString(list)
Upvotes: 2
Views: 5154
Reputation: 58128
Yes, your example is terrible :P it is still not clear what you are trying to do. I just tried this and it worked:
* def randomPhoneString = function() { var rand = Math.random(); return Math.floor(rand * 100000000) + '' }
* def temp = randomPhoneString()
* print temp
It printed:
[print] 59303272
Upvotes: 2