rixoto
rixoto

Reputation: 33

Karate Framework - How to use declared variables as parameters of request object?

First of all, sorry if I'm asking something obvious as I don't come from a programming background, there I go:

I'd like to run a series of test Scenarios and have declared couple variables in the Background part (I have print them to double check they have been correctly declared), the first one is an integer and the other two strings as you can see.

The problem is that when I try to use them as parameters of the request object, it doesn't seem to work. Is this I want possible? Then, am I doing it wrong? The idea is that I have to change only the Background part for it to apply to all scenarios.

Thanks a lot in advance!

Upvotes: 3

Views: 7842

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

I think you have to understand "embedded expressions": https://github.com/karatelabs/karate#embedded-expressions

So this should work:

Background:
* def bar = 'something'

Scenario:
* request { foo: '#(bar)' }

Upvotes: 3

Related Questions