Testing / Karate Framework Interview questions
What is the difference between path and param keywords in Karate?
path appends segments directly into the URL's path portion, while param adds a key-value pair to the URL's query string. Mixing the two up produces a request to the wrong URL shape entirely, even if both look similar at a glance in the feature file.
Given url baseUrl And path 'users', userId And param includeOrders = true And param status = 'active' When method get # results in: GET {baseUrl}/users/{userId}?includeOrders=true&status=active
| path | param |
| Builds the URL's path segments. | Builds the URL's query string. |
| Typically used for resource identifiers. | Typically used for filters, pagination, or optional flags. |
Example result: /users/42 | Example result: ?status=active |
Whether a given piece of an API's URL should be a path segment or a query parameter is dictated by how the target API itself is designed, Karate doesn't decide this; using the wrong one against a real API results in a 404 or an unexpected response, since the request sent simply won't match what the API expects.
More Related questions...