1

I want to pass an argument to karate graphql test from selenium java test. I tried to do that this way, but it didn't work.

HashMap<String, Object> args = new HashMap<String, Object>();
args.put("argument1", "value1");
Map<String, Object> result = CucumberRunner.runFeature(featureFile, 
args, true);

I tried to put that value in karate file in ways like

<argument1>

or

#(argument1)

but literally this text was passed to query in karate test. Have someone done that by karate?

Here you have fragment of my feature file:

Given text query =
"""
{
  element(name:"<argument1>") {
    name
  }
}
"""
And request {query: '#(query)'}
When method post
Then status 200
* print response

1 Answer 1

2

I think you missed a replace, try this:

Given text query =
"""
{
  element(name:"<argument1>") {
    name
  }
}
"""
And replace query.argument1 = argument1
And request {query: '#(query)'}
When method post
Then status 200
Sign up to request clarification or add additional context in comments.

Comments

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.