1

I am trying to call an API in second feature file , passing arguments from first feature file . Say token and current page value which is returned from a first API response.These has to be passed as a param for second API

   * def activeDetails =
    """
      function(times){
        for(i=0;i<=times;i++){
          karate.log('Run test round: '+(i+1));
          karate.call('getActiveRouteDetails.feature', { token: token, currentPage: i });
        }
        java.lang.Thread.sleep(1*1000);
      }
    """
* call activeDetails totalPages

In my second feature , I am able to print the values passed , but unable to pass in params . Can you please help me

And print currentPage
And print token
And param pageNumber  = '#currentPage'
And param token = token

1 Answer 1

3

There is a subtle difference when you are in a JavaScript block. Please read this: https://github.com/intuit/karate#karate-expressions

Make this change:

var result = karate.call('examples/getDetails.feature', { token: token, currentPage, i });

And please don't have variable names like current page, take the help of a JavaScript programmer friend if needed for help.

Also note that the best practice is to avoid JS code and loops as far as possible: https://github.com/intuit/karate#loops

Sign up to request clarification or add additional context in comments.

1 Comment

@PeterSmith Thank you Sir.I will update the code after going the links you provided. I am facing another issue as mentioned. Can you please provide your input

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.