karate

Karate: I would like to assert to match parts of response

我是研究僧i 提交于 2020-01-04 05:07:33
问题 Karate: I would like to assert to match parts of response I am getting the following response: 12:10:33.960 [print] Kyc Status changed from NotStarted to Accepted.Reason: Output Address AddressLine : 6927 14TH AVE But I would like to only make assertion to match part of the response. e.g.: "Kyc Status changed from NotStarted to Accepted." 回答1: The following examples should solve your problem: Scenario: Matching text * def yourResponse = "12:10:33.960 [print] Kyc Status changed from NotStarted

Karate API Testing - Passing variable from one feature file to another

时间秒杀一切 提交于 2020-01-02 18:05:40
问题 I am looking to pass Authorization Header as a variable to another feature file. Here is an example I am trying to do: Feature: Resource Creation Background: * url baseUrl Scenario: Create Resource Given def basictoken = 'Basic Zn*****' And def token = call read('classpath:endpoints/UserLogin.feature') Given path 'lobs' And header X-XSRF-TOKEN = token.xsrftoken And header Cookie = 'SESSION='+token.scookie+'; '+'XSRF-TOKEN='+token.xsrftoken And request [{"name":"Boston"}] When method post Then

Karate Framework - Why Javascript function returns an array with NaN values?

拟墨画扇 提交于 2019-12-29 09:27:23
问题 I wrote javascript function in Karate scenario and the function takes in current date in argument and gets date, year, month and adds them in a array. But for some unknown reason I get NaN values. Please see below karate steps that I have been using. * def dateArr2 = [] * def dateParse = """ function(myOrderDate) { dateArr2.add(myOrderDate); // this is for test purpose var today = new Date(myOrderDate); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today

Karate How to Escape quotes in data you're passing to a Java type call

拈花ヽ惹草 提交于 2019-12-25 17:37:50
问题 This is related to this Karate Java Function problems So I have a feature that calls a java method that makes a query to a database and it passes data to that method but as not all the data is made of only numbers I have to put it in quotes "Something" but the method also gets the quotes and that results in my query to be empty, how can I escape the quotes to avoid receiving empty results? Backslashes in def query = sql.identificacionCliente('<numeroCuenta>') don't work. 回答1: Mi inexperience

How to add conditional wait for a response in karate?

为君一笑 提交于 2019-12-24 21:52:01
问题 For one of our DELETE request time taken is more than 30 sec. Sometimes tests fails if it takes more than 30 sec. I need to add wait for response until certain GET call passes. I tried below code. But I wants to check some condition in GET call then I wants to assert for DELETE call. Feature: Background: * def waitUntil = """ function(x) { while (true) { var result = karate.call('classpath:ic/feature/soap/Common/getApplicationsList.feature'); var res = result.response; karate.log('poll

Is there a way to run Karate test during maven's integration test phase?

有些话、适合烂在心里 提交于 2019-12-24 19:43:19
问题 Is there a way to run Karate test during maven's integration test phase? It seems that surefire plugin is hardcoded into Karate. I have tried to override it using failsafe plugin but with no luck. I don't want test to run along with unit tests. Thank in advance! 回答1: It seems that surefire plugin is hardcoded into Karate I'm not sure where you got that impression, but no, the surefire plugin is not hardcoded into Karate. Keep in mind that the simplest way to not run a JUnit test via surefire

Karate - Validate json responses stored in different files

南楼画角 提交于 2019-12-24 17:27:10
问题 I need to validate 2 json responses which are stored in two different files. I am reading them and comparing. But i get an error reason: all key-values did not match and there're few elements not being matched. This problem occurs only when i store the json in a file and read in my feature file. Json File 1: Test.json { "webServiceDetail":{ "feature":{ "featureCd":"ABCD", "imaginaryInd":"100.0", "extraInd1":"someRandomValue1" }, "includefeatureList":[ { "featureCd":"PQRS", "featureName":

How to use karate.callSingle() in my karate-config.js?

青春壹個敷衍的年華 提交于 2019-12-24 17:16:35
问题 The following is my karate-config.js file. The classpath for the feature that i want to call only once is classpath:com/test/scenario/accessToken.feature . where should i include the karate.callSingle() function init() { karate.log('Env set to ', karate.env); karate.log('baseURL ', karate.properties['baseURL']); karate.log('OriginURl',karate.properties['OriginURL']) return { env: karate.env, SECRET: karate.properties['clientSecret'], TOKEN: { "CSRF": "", 'ACCESS': "" }, } }; } 回答1: You can

Best way to do Karate match using “==” and “contains” using generic script

孤者浪人 提交于 2019-12-24 14:02:39
问题 This question is resulting from a previous question here Lets says our implemented server v1 and v2 response looks as follows * def v1Response = { id: "1", name: "awesome" } * def v2Response = { id: "2", name: "awesome", value: "karate" } Similarly we define the client schema for v1 and v2 like as follows * def v1Schema = { id: "#string", name: "#string } * def v2Schema = { id: "#string", name: "#string, value: "#string" } From the above given data, all I want is to test following three cases

How to make a Odata batch call in karate

南楼画角 提交于 2019-12-24 12:33:25
问题 I need to make Odata call to fech the results from downsream APIs. I am using karate to test our APIs. But now i need to fech the data from downstream APIand compare it with our APIs result. My problem is downstream APIs are Odata request. Can i make Odata batch request from karate. if yes how? Request header is: Content-Type = 'multipart/mixed;boundary=batch_01' and Request body is: --batch_01 Content-Type: application/http Content-Transfer-Encoding: binary GET test(test1='ABC',test2='12345'