I am facing issue . when i am using a script java in my feature file its not supporting line break it gives syntax error .
here are the details
screen shot
Feature: Create Licenses key from POST Request
Background: Define URL
* def config = call read('../../../java/karate-config.js')
* def ThelicenseKeys = []
* def iterations = 5
Given url config.Given_url
@single
Scenario: Create multiple license keys
* def ThelicenseKeys = []
* def iterations = 5
* def loop = function(i) { var randomLicenseKey = config.dataGenerator.getRandomLicenseKey(); karate.log('Creating License Key:', randomLicenseKey); karate.set('randomLicenseKey', randomLicenseKey); }
#* karate.repeat(iterations, function(i) { And request { license_key: '#(randomLicenseKey)'; valid_for: 20 ; status: "active" ; times_activated_max: 3 } When method post ; Then status 200 });
* karate.repeat(iterations, function(i) {
Given path 'licenses'
And request
"""
{
"license_key": #(randomLicenseKey),
"valid_for": 20,
"status": "active",
"times_activated_max": 3
}
"""
When method Post
Then status 200
})
* karate.repeat(iterations, loop);
* print 'All Created License Keys:', ThelicenseKeys
* print 'Response:', response
* eval ThelicenseKeys.push(response.data.licenseKey);
this error shown
01: karate.repeat(iterations, function(i) {
<<<<
org.graalvm.polyglot.PolyglotException: SyntaxError: Unnamed:1:39 Expected } but found eof
karate.repeat(iterations, function(i) {
^
kindly guide my and help me to fix it
i have tried many combinations but still i am unable to fix it .
eg :
1.wrote loop code in 1 line
2.tried karate.repeat function
3.tried karat.call
4.Write simple while and for loop code
5.execute single post request which working
SyedNaumanAli is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2