karate

Capability of using Karate along with selenium webdriver

牧云@^-^@ 提交于 2019-11-29 12:28:26
I started using Karate one week back and this is my first question. I used to write web service tests using Spock & groovy, Rest assured & cucumber. When I came across Karate I felt it's really interesting. Thank you for your huge effort. I found Karate really capable and satisfying my needs to automated Json services. However, I would like to know some more details on this. I use another framework along with groovy, Spock and Java. In my scenario, I need to send a json request, get the transaction id from the response and then execute the UI test using selenium web driver. How can I easily

Is it possible to have multiple JS functions inside one JS file of karate framework?

僤鯓⒐⒋嵵緔 提交于 2019-11-29 08:46:51
I need to perform two operations on the result of JSON responses.so can we have those different operations inside single JS file? or do we need to have mapping like one JS file for one operation. Please help on this I don't recommend trying to create complicated JavaScript in Karate, it just leads to maintainability issues. If you really want an object with multiple utility methods on it, write a Java class with static methods, and it will be much easier to maintain / debug. That said, if you really insist - look at this answer: https://stackoverflow.com/a/47002604/143475 But this is what I

Error using DBUtils in first scenario

十年热恋 提交于 2019-11-28 14:22:13
When I use DBUtils.java in Eclipse and run the tests there it works fine, but when I run it through Jenkins the first time that DBUtils are used is failing. And the second works... The first time that it uses db.readRows it fails. Scenario: Account Create Given path 'accounts' And header Authorization = setup.authorization And request {identifier: KarateCreation, subscribers:[{identifier:KarateCreation, firstName:KarateCreation, lastName:KarateCreation}]} When method POST And match response contains { id: '#number', identifier: KarateCreation } Then status 201 * def id = response.id * def

How to read input data from an excel spreadsheet and pass it JSON payload in karate framework?

不想你离开。 提交于 2019-11-28 12:36:29
I need to create data driven unit tests for different APIs in karate framework. The various elements to be passed in the JSON payload should be taken as input from an excel file. A few points: I recommend you look at Karate's built-in data-table capabilities, it is far more readable, integrates into your test-script and you won't need to depend on other software. Refer these examples: call-table.feature and dynamic-params.feature Next I would recommend using JSON instead of an Excel or CSV file, it is natively supported by Karate: call-json-array.feature Finally, if you really wanted to, you

Is there a way to write to a text file using Karate

核能气质少年 提交于 2019-11-28 10:58:17
问题 In my karate tests i need to write response id's to txt files (or any other file format such as JSON), was wondering if it has any capability to do this, I haven't seen otherwise in the documentation. In the case of no, is there a simple JavaScript function to do so? 回答1: Try karate.write(value, filename) in JavaScript. We have kept this un-documented because we don't encourage it. Also the file will be written only to the current "build" directory which will be target for Maven projects /

Handling JWT bearer token from ADFS

不打扰是莪最后的温柔 提交于 2019-11-28 10:47:27
问题 I'm testing a web application API that do authentication against an ADFS server with X509 certificates. In order to run tests with Karate, I currently use a small .NET application that negotiates the JWT for SSO using my installed certificate. I then get the bearer token header line from Fiddler and manually put it into my Karate tests. There's an example on how to use oauth with form fields here, and I'm looking for the equivalent version when using certificates. Is there a clever way of

How to compare XML response with Json in Karate

徘徊边缘 提交于 2019-11-28 10:13:24
问题 I need to match and validate my JSON response with that of downstream XML response. Here are sample responses for both. Note that Json response parameters are is not in-order with XML response. JSON RESPONSE "Main": { "Cd": "ABC", "descriptionTxt": "Sample Main", "type": "A", "codeType": "P", "dt": "2018-10-15T00:00:00-05:00", "validity": "3", "segment": "Personal" }, "testList": [ { "code": "123", "descriptionTxt": "My Description", "categoryCd": "DUDU" }, { "code": "675", "descriptionTxt":

Cannot use “==” and “contains” in same line of scenario using conditional logic in Karate

孤者浪人 提交于 2019-11-28 10:06:08
问题 This is a follow up of a question noted here Lets says our implemented server v1 and v2 response looks as follows v1Response = { id: "1", name: "awesome" } v2Response = { id: "2", name: "awesome", value: "karate" } Similarly we define the client schema for v1 and v2 like as follows v1Schema = { id: "#string", name: "#string } v2Schema = { id: "#string", name: "#string, value: "#string" } We implement schema validation in our generic scenario as follows. We can easily set the "response" with

Karate API Testing - Reusing variables in different scenarios in the same feature file

我是研究僧i 提交于 2019-11-28 09:05:56
问题 Does Karate supports a feature where you can define a variable in a scenario and reuse it in other scenarios in the same feature file. I tried doing the same but get an error. What's the best way to reuse the variables within the same feature file ? Scenario: Get the request Id * url baseUrl Given path 'eam' When method get Then status 200 And def reqId = response.teams[0]resourceRequestId Scenario: Use the above generated Id * url baseUrl * print 'From the previous Scenario: ' + reqId Error:

Karate framework retry until not working as expected

谁说胖子不能爱 提交于 2019-11-28 06:22:55
问题 I'm using Karate framework with JUnit. Using this feature: Given path 'save_token' And request """ { "token": "test_token" } """ And retry until response.tokens == """ [ "test_token" ] """ When method POST I'm having this exception: java.lang.ArrayIndexOutOfBoundsException: 1 at com.intuit.karate.core.MethodMatch.convertArgs(MethodMatch.java:60) at com.intuit.karate.core.Engine.executeStep(Engine.java:141) at com.intuit.karate.core.ScenarioExecutionUnit.execute(ScenarioExecutionUnit.java:171)