karate

Karate UI - Maintain browser cookies/session/local storage variable value accorss different scnearios

蹲街弑〆低调 提交于 2021-01-28 09:39:26
问题 I am testing various components of my website and to test each component there is a pre-requisite that user must be logged in. When user login to website web server creates the cookie in the browser which then allow the user to access those components/pages. Now to test each component, for which I am writing several scenarios, I am writing login code every time in the scenarios because whenever my scenarios starts using the following line @tag Feature: User List I want to use this template

Parallel execution with multiple users in karate

半世苍凉 提交于 2021-01-28 09:30:00
问题 My requirement is : I want to have parallel execution with say 5 thread. All thread would be creating an entity.I want to have more threads so that text execution time could be less.But I am facing issue as when threads are increasing ,I get error from db saying unable to lock the error as all threads are using same user to create an entity.Is it possible in karate that I can use multiple user credentials so that threads can pick users randomly and create an entity?? 回答1: Simple solution,

Parallel execution with multiple users in karate

我只是一个虾纸丫 提交于 2021-01-28 09:23:35
问题 My requirement is : I want to have parallel execution with say 5 thread. All thread would be creating an entity.I want to have more threads so that text execution time could be less.But I am facing issue as when threads are increasing ,I get error from db saying unable to lock the error as all threads are using same user to create an entity.Is it possible in karate that I can use multiple user credentials so that threads can pick users randomly and create an entity?? 回答1: Simple solution,

A bit confusion with exists in karate?

試著忘記壹切 提交于 2021-01-28 08:12:06
问题 I am using exist for an element whose visibility is conditional like this * if (locate('#elusivePopup').exists) click('#elusiveButton') But when the element is not visible it gives an error as "cannot find locator #elusivePopup"? version 0.9.6.RC4 回答1: This changed in 0.9.6.RCX https://github.com/intuit/karate/issues/1148 * if (exists('#epp')) click('#eb') 来源: https://stackoverflow.com/questions/63392370/a-bit-confusion-with-exists-in-karate

Karate - Ability to execute tests on a specific set of data in a csv file

会有一股神秘感。 提交于 2021-01-28 08:10:21
问题 I am on a team, presenting the advantages of Karate to move forward as the framework of choice for our API testing. However, I have come across a couple questions, in regards to data-driven testing. I have gone through the documentation, csv files and cannot find a solution for this question: Is Karate capable of executing tests on specific data sets (For instance, based on priority p0, p1) given in a csv file? Example "test.csv": |priority|data1| | p0 | 1 | | p0 | 2 | | p1 | 4 | | p1 | 6 | I

Matching key value pairs in a request in a Karate Netty scenario

蓝咒 提交于 2021-01-28 08:07:24
问题 I'm writing features for a Karate Netty mock service and I'm trying to use the Scenario to match on a key value pair in the request. For example: In a request like this one that has a nested array of objects, I want this feature to fire when any of the Id values are null: { "Array": [ { "Id": "legitId" }, { "Id": null } ], } Scenario: pathMatches('path/to/my/endpoint') && methodIs('post') && request.Array.contains('Id': null) The documentation says I can use JS expressions in the scenario,

incompatible cucumber json report between karate and cucumber

有些话、适合烂在心里 提交于 2021-01-28 07:43:52
问题 I am trying to import json results from karate tests into the AssertThat Jira plugin. Importing works well with cucumber js 5.1.0, but fails using karate 0.9.2 Seems that the problem lies in AssertThat using the Feature's "name" in the json to correlate to its internal Feature names, and a difference between how karate and cucumber js use the "name" and "description" fields . Cucumber js uses the Feature's name from the feature file itself e.g. a feature file with "Feature: test reporting"

Karate mock - how to match against request body content

旧街凉风 提交于 2021-01-28 07:34:36
问题 With Karate, I'm trying to work out how to return different mock responses based on the content of the request body. I've got Feature: ... Scenario: pathMatches('/users/login') && methodIs('post') && request == {"username": "gooduser", "password": "goodpassword"} * def responseStatus = 200 * def response = {"status: login ok"} Scenario: pathMatches('/users/login') && methodIs('post') && request == {"username": "baduser", "password": "badpassword"} * def responseStatus = 401 * def response = {

Does '!contains' can “compare” String with String in Karate?

送分小仙女□ 提交于 2021-01-28 06:15:44
问题 We read very carefully the github repo, but we can't find if we can do: 'foo' !contains 'bar'. Exemples show only: * match foo !contains { huh: '#notnull' } > json * match foo !contains 4 > int * match foo !contains [5, 6] > array Can we do it with String? 回答1: Great question, this is indeed not possible today, but we opened a ticket for this: https://github.com/intuit/karate/issues/201 Meanwhile you can do this via an assert and JavaScript: * def foo = 'Hello World' * assert foo.indexOf(

Can we have option to filter the data using Karate scripts?

ε祈祈猫儿з 提交于 2021-01-28 06:11:07
问题 I have below JSON response: { "name": "Cabinets, Enclosures and Racks", "parentId": "", "categoryId": "55040", "count": "3291", "categoryLevel": "TOP" }, { "name": "Cable Management and Accessories", "parentId": "55040", "categoryId": "55041", "count": "573", "categoryLevel": "MIDDLE" }, { "name": "Cable Management", "parentId": "55041", "categoryId": "55042", "count": "467", "categoryLevel": "BOTTOM" }, I need to fetch the only TOP CategoryLevel data. Is there any option to do so 回答1: Yes,