karate

If then else implementation to chose baseURL in Karate DSL

折月煮酒 提交于 2020-08-19 08:54:42
问题 I have a little tricky requirement in Karate. I have a set of baseURL's in my karate.config which are chosen based on the implementation. Here is the snippet of it: if (env == 'qa') { config.apiKey = apiKey; config.tsp_api = 'https://api.qa.tceu.net'; config.svt_dcm = 'https://svt.qa.tceu.net'; config.acn_dcm = 'https://acn.qa.tceu.net'; config.sos_dcm = 'https://sos.qa.tceu.net'; config.cust_dcm = 'https://cust.qa.tceu.net'; Here tsp,svt,acn,sos,cust are some actions. I have a feature file

How to match field value in response when there are multiple fields with the same name?

六月ゝ 毕业季﹏ 提交于 2020-08-10 20:14:26
问题 [ { "key": "test1", "category": "test", "name": "test1", "translations": { "english": "eng" } }, { "key": "test2", "category": "test", "name": "test1", "translations": { "english": "eng2", "german": "German" } }, { "key": "test3", "category": "power", "name": "test1", "translations": { "EN_lang": "jik" } } ] Here, we have multiple field's are with different values and we have to match value in translations (field position will change on every call) 回答1: You have to be clear about what you

failed features: failed to get reply for: [id: 6, method: Page.navigate, params: {url=https://github.com/login}]

拟墨画扇 提交于 2020-08-10 19:16:40
问题 I am trying to setup karate for UI automation on Windows Laptop. I tried to run the sample code on the zip release 0.9.5 this is what I get. failed features: src.demo.web.google: google.feature:10 - failed to get reply for: [id: 6, method: Page.navigate, params: {url=https://github.com/login}] the full stack trace is feature: src/demo/web/google.feature:7 report: target\surefire-reports\src.demo.web.google.json scenarios: 1 | passed: 0 | failed: 1 | time: 19.1133 -----------------------------

Karate UI Scroll till the end of dynamic page

我怕爱的太早我们不能终老 提交于 2020-08-10 03:38:49
问题 Can it be possible in karate to scroll till the end of a dynamic page I tried using scroll and wait but it's not working? 回答1: It may be tricky for a dynamic page. I suggest you look into using JS. Refer this answer for ideas: https://stackoverflow.com/a/60800181/143475 If you provide a live example, we can investigate more, or follow this process: https://github.com/intuit/karate/tree/develop/examples/ui-test 来源: https://stackoverflow.com/questions/63148346/karate-ui-scroll-till-the-end-of

Karate UI Scroll till the end of dynamic page

落爺英雄遲暮 提交于 2020-08-10 03:38:32
问题 Can it be possible in karate to scroll till the end of a dynamic page I tried using scroll and wait but it's not working? 回答1: It may be tricky for a dynamic page. I suggest you look into using JS. Refer this answer for ideas: https://stackoverflow.com/a/60800181/143475 If you provide a live example, we can investigate more, or follow this process: https://github.com/intuit/karate/tree/develop/examples/ui-test 来源: https://stackoverflow.com/questions/63148346/karate-ui-scroll-till-the-end-of

What does the Efficiency field in the Karate output table represent? Efficiency compared to what?

痴心易碎 提交于 2020-08-09 18:06:10
问题 I was wondering as to what the Efficiency field in the Karate output table in the console represent. I see it has a value of 0.98 after i execute my tests, so it is 98% efficient. But compared to what? Seems no one had this question earlier i suppose. 回答1: Simple search through the source (https://github.com/intuit/karate/blob/9992eaf8d7b9dd637477a0970de1a1187b820fc2/karate-core/src/main/java/com/intuit/karate/Results.java#L163) tells us that: public double getEfficiency() { return

Karate: compare csv data with api response

孤街浪徒 提交于 2020-08-09 09:24:06
问题 I have a use case where I want to assert on a API response and compare it with the csv data. Step1: Csv file: *test.csv* id,date,fullname,cost,country,code 1,02-03-2002,user1,$200,Canada,CAN 2, 04-05-2016,user2,$1500,United States, USA I read the csv file and store it in a variable def var1 = read(test.csv) So now, var1 is a list of jsons based on my csv var1 = [ { "id":1, "date":"02-03-2002", "fullname": "user1", "cost": "$200", "country": "Canada", "code": "CAN" }, { "id":2, "date":"04-05

Using match each contains for json array items assertion

喜你入骨 提交于 2020-08-09 09:09:33
问题 I would like to add an assertion on skills array containing 'training' in each of the items under response array. how can I do this using match each format * match each response contains { password: 'abc123' } (without using JsonPath expression). I'm expecting my test to be failed for below example since skills array is missing in fourth object. Scenario: Test scenario * def response = """ [ { id: 1, name: "John", password: "abc123", skills :[ "training", "management" ] }, { id: 2, name:

Attaching screenshots to json report

坚强是说给别人听的谎言 提交于 2020-08-08 03:41:50
问题 What is the easiest way to attach screenshots to Karate JSON report? We test REST API and our tests cases require to perform some operation on web side(log into web application, perform verification, take screenshot). We've handled with it writing some static methods which are called from Karate using Java interop mechanism. What I want to do is write some generic, reusable code to attach screenshots taken during test execution. I don't want to repeat steps: * def bytes = getScreenBytes() *

Can anyone explain how to get all the mismatch between two responses in karate?

前提是你 提交于 2020-08-03 08:30:34
问题 Like if I have two JSON as below and I want to check the mismatch between those Json 1: { name:'john', contact:'123', country:'america' } Json 2: { name:'vishal', contact:'123', country:'India' } Now it will return me with the mismatch between name and country not only the name? 回答1: No this is not supported. We feel this is not needed, because in your regular CI runs you only care if the test passed or failed, and you see the details in the log. Also note that you can simulate this if you