sebilet
sebilet

Reputation: 69

How can I use eval for conditional feature call with parameters?

I wanted to call another feature file in a feature file with parameters but if a data value of previous api's response is true. And after running this eval function I wanted to it continue to run other parts of my main feature. I wrote this code;

But I can't use eval like this. How can I achieve my aim that I explained above?

I've tried conditional logic methods which explained in Karate intuit page. But I couldn't solve my problem.

As I expect error, Karate gave me these logs; com.intuit.karate.exception.KarateException: content-filter.feature:26 - javascript evaluation failed: if (response.data.eula == true) ; karate.call('classpath:eulasign/eula-sign.feature') { no: '#(no)' , password: '#(password)'}, :1:135 Expected ; but found { if (response.data.eula == true) ; karate.call('classpath:eulasign/eula-sign.feature') { no: '#(no)' , password: '#(password)'} ^ in at line number 1 at column number 135

Upvotes: 1

Views: 1818

Answers (1)

Adrien
Adrien

Reputation: 1090

You are mixing karate.call and call read. It's either karate.call(fileName, [arg]) or call read(filename) { arg }

So in your case with karate.call, the variables no and password have to be passed in JSON format as the second argument of your function.

Upvotes: 2

Related Questions