karate

Karate API Tests - Escaping '?' in the url in a feature file

十年热恋 提交于 2019-12-04 15:41:09
I am using the path keyword from Karate API framework to concatenate strings to form a url. However, I am not able to pass '?'. Here is what I am doing: Background: * url 'https://api.cloud.abcde.com/animal/' Scenario: Verify the get status Given path 'herbivore?id=25' When method get Then status 200 When I run the test, i see the '?' being passed as %3F. I tried to escape it using \ and tried some other answers too but couldn't succeed. Do I need to use url encoding ? Any pointers or help would be appreciated. Thanks You should use param for this case: Scenario: Verify the get status Given

I want to pass multiple arguments in karate-config.js through mvn command

陌路散爱 提交于 2019-12-04 12:58:47
I want to want pass multiple arguments in mvn command and and that should be read in karate-config.js file. e.g: mvn test -DargLine="-Dkarate.env='gdcStaging', -Dkarate.source='false', -Dkarate.natco='gdc'" I didn't want to declare any .prop files, want to get these values at run time. Below prop. are defined to read these arguments but unable to achieve from this: var environment = karate.env; var natco = karate.properties['karate.natco']; var isLocal = java.lang.System.getenv('karate.source'); I need help to achieve this karate-version=0.9.0 I had also referred to this link : Pass additional

Karate array field become object when it is returned from JS function

半城伤御伤魂 提交于 2019-12-04 05:21:41
问题 I'm trying to compare response with predefined JSON (expected) generated by JS function. JS: function(fleetId) { var result = {}; result.name = "TestConnection"; result.fleetId = fleetId; result.connectionConfigDefault = { "configParameters": [{ "keyName": "N/A", "value": "testValue" }], "id": 4 } return result; } Test: ... Then match connection.response == """ { connectionConfigDefault: '#(connectionJson.connectionConfigDefault)', fleetId: '#(connectionJson.fleetId)', id: '#number', name: '#

Karate: JsonPath wildcards didn't work or partly didn't work

醉酒当歌 提交于 2019-12-04 02:23:55
问题 JSON file jsonExample : { "store": { "book": [ { "category": "fiction", "author": "Evelyn Waugh", "title": "Sword of Honour", "something": 12.99 } ], "bicycle": { "color": "red", "price": 19.95 } }, "expensive": 10 } I want update "something" . When I use: 1) * set jsonExample $.store.book[0].something = 13 - it is working 2) * set jsonExample $..book[0].something = 13 - it is working 3) * eval jsonExample.store.book[0].something = 13 - it is working BUT 1) * set jsonExample $..something = 13

Karate karate-config.js not a js function

徘徊边缘 提交于 2019-12-04 01:44:58
问题 I'm trying use karate for e2e tests and have started with a minimal setup. I want to create some config items in karate-config.js for use in the tests but karate is reporting that file is not a js function and hence the test fails trying to get the config: Warning: Nashorn engine is planned to be removed from a future JDK release 12:16:35.264 [Test worker] WARN com.intuit.karate - not a js function or feature file: read('classpath:karate-config.js') - [type: NULL, value: null] ---------------

How to use dynamic values for Karate Features

对着背影说爱祢 提交于 2019-12-02 14:01:23
问题 I've a need where I should use dynamic values in the features of my karate tests. I've came accross with some of the questions and answers like this: How to read input data from an excel spreadsheet and pass it JSON payload in karate framework? But no mather what how hard I try, I couln't make it happen. I believe I should share the code parts that I am trying to use, so that a discussion can start. I have a SOAP request for creating new users as below: <?xml version="1.0" encoding="utf-8"?>

How to test each date field in the array response using Karate

帅比萌擦擦* 提交于 2019-12-02 09:34:33
问题 i have response like { Data: {a: [{ date1: "2018-12-23", date2: "23-11-2018" },{ date1: "2018-12-20",date2: "23-11-2018" }] } } and want to test if each date1 field is less than today's date and each date2 is less than input date field (i have a date field in input payload) How can i perform that. 回答1: In many ways, here is one. Refactoring this code to be cleaner is homework for you :P * def toTime1 = """ function(s) { var SimpleDateFormat = Java.type('java.text.SimpleDateFormat'); var sdf =

How to use dynamic values for Karate Features

 ̄綄美尐妖づ 提交于 2019-12-02 07:53:13
I've a need where I should use dynamic values in the features of my karate tests. I've came accross with some of the questions and answers like this: How to read input data from an excel spreadsheet and pass it JSON payload in karate framework? But no mather what how hard I try, I couln't make it happen. I believe I should share the code parts that I am trying to use, so that a discussion can start. I have a SOAP request for creating new users as below: <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xxxxxx> <soapenv:Header/> <soapenv:Body> <int:createSubscriber soapenv:encodingStyle=

Karate - How to import json data

我怕爱的太早我们不能终老 提交于 2019-12-02 07:01:53
问题 I want to import some JSON data to my tests. In order to documentation I should do that like this: * def data = read('classpath:init/data.json') I've created my JSON file with this content: { "name": "ehsan" } This is my code: Background: * def data = call read('classpath:init/data.json') Scenario: * print data But it prints nothing and says: 16:11:30.898 [main] WARN com.intuit.karate - not a js function or feature file: read('classpath:init/data.json') - [type: JSON, value: com.jayway

Can we loop feature files and execute using multiple login users in karate

℡╲_俬逩灬. 提交于 2019-12-02 06:06:19
问题 For our project requirement we have to run the feature file using 50 users . For now I am able to run using one user which is configured in the karate.config file. I need to configure these 50 users in the config file and run the same feature file for all 50 users. Looking for a way to configure all users in one config file and run the feature file. 回答1: Here's my suggestion. Don't overload your config file like this. Use a JSON file with an array of users. Now you can read this JSON file