Questions tagged [karate]

Use for questions regarding Karate, an open-source tool that combines API test-automation, mocks, performance-testing and UI automation - into a single, unified framework.

Karate is the only open-source tool that combines API test-automation, mocks, performance-testing and UI automation into a single, unified framework.

Karate uses a language-neutral BDD syntax, which is easy for even non-programmers. Besides powerful JSON & XML assertions, you can run tests in parallel for speed - which is critical for HTTP API testing.

You can easily build (or re-use) complex request payloads, and dynamically construct more requests from response data. The payload and schema validation engine can perform a 'smart compare' (deep-equals) of two JSON or XML documents, and you can even ignore dynamic values where needed.

Test execution and report generation feels like any standard Java project. But there's also a stand-alone executable for teams that are not comfortable with Java. Just write tests in a simple, readable syntax - carefully designed for HTTP, JSON, GraphQL and XML.

4221 questions
1
vote
1 answer

How to reduce the decimal length to upto two decimal places in karate framework

Below function is returning the output is 8.110000000000001. I want the output only upto two decimal places. i.e) 8.11 def array = [2.16,1.34,1.32,1.25,0.65,0.48,0.42,0.26,0.14,0.06,0.03,0] def result = 0 def fun = function(x){ var temp =…
Narasimha
  • 21
  • 3
1
vote
2 answers

How to remove the unwanted characters from integer array in karate framework

Below is the function and its returning the integer values with %. def functions = [] eval for(var i=0; i
Narasimha
  • 21
  • 3
1
vote
1 answer

Is there a class/variable of karate available to get the details of failed scenarios like failed Scenario name, count etc when run using TestRunner

I want to get the details of the failed testcase after running it using TestRunner class. I was able to get few details like error messages, failed count of scenarios and feature files using the Result class of karate. Results results =…
1
vote
1 answer

karate framework save response from 1 request and then use in another request

In karate frame work is it possible to save response from 1 request and then use it in request body of another request? Example: in Request 1 I send user name and user id in request body and in response I get user address. In request 2 body, I want…
Sheikh Rahman
  • 895
  • 3
  • 14
  • 29
1
vote
0 answers

Is there a way to override the old karate-reports folder with the new karate-report folder instead of creating new reports folder for each execution

Each time I run a feature file as a cucumber feature or using TestRunner class, a new karate-reports_x is being generated inside the target folder. This is leading to more memory consumption. So I'm forced to manually delete the karate-reports…
1
vote
0 answers

How to read .ENV values in Karate

I'd like to remove secrets from my karate-config.js and place them in a .ENV file (which is in the .gitignore). That way I can run the Karate tests on various environments (local and Azure Devops pipelines) and only have to set the right environment…
RuSm
  • 27
  • 1
  • 5
1
vote
0 answers

scenario count is not visible while executing cucumber html report in karate API

enter image description here Runs is displaying as 1/1.. Is there any way to show the number of scenarios executing while using cucumber html report? public class TestRunner { @Test public void testParallel() { Results results =…
Aasha
  • 11
  • 1
1
vote
0 answers

How to Generate an Excel Report from TestRunner class in cucumber (like HTML report)

Generate test report in excel after execution of testcase and should have testcase status, time, failedreason, failed scenario, failed step
Saeedanwar
  • 11
  • 1
1
vote
1 answer

Karate : Is there a way yo get a specific value as a string instead of an array when using jsonPath

Karate : Is there a way yo get a specific value as a string instead of an array when using jsonPath My Requirement is i'm trying to get a specific value from the response and trying to assign it to another variable using jsonPath. but the value is…
1
vote
1 answer

Karate match error: match failed: EQUALS $ | data types don't match (OTHER:MAP)

I have a scenario that reads a json field from a file and compares it to another json field. When I do the match, it says the field from the file is type "other". Sorry for the screen shots, but I think the print statements are helpful. This is the…
1
vote
1 answer

Get the value from the response based on a condition and store it to a variable

I would like to get the value from the response based on a condition and store it to a variable. In the below JSON, I would like to store the value when the name matches to something I prefer. Is there a way to achieve this using Karate API? { …
1
vote
1 answer

Karate - To find the occurrence of element in a list and print the number of times its present in the list

In my case list A = [a,a,a,b,b,c] I have to find the occurrence of the elements available in the list and print their counts For example print as a=3, b =2 and c =1
1
vote
0 answers

How to integrate swagger into karate framework

I want to integrate swagger with karate framework. I searched on the internet for the resources but I couldn't find any resource to integrate swagger with karate framework. Is there any way to integrate swagger with karate?
1
vote
0 answers

Compare JSON key values

How to Compare two JSON structure and return the result. We are able to compare the keys but not the key values. def result = karate.match(result1,result2).pass ? { pass: true } : { pass: false} print result Is there any way to compare structure…
1
vote
1 answer

How do I call a variable in scenario SA of feature file FA from a scenario SB of a feature file FB?

In Karate, I have following: Feature file FA containing scenario SA and Feature file FB containing scenario SB String Variable VA is generated in scenario SA. From scenario SB, I would like to initialize a new string variable VB by calling the…
astar
  • 111
  • 2
  • 12
1 2 3
99
100