karate

How to do conditional Karate abort based on response

守給你的承諾、 提交于 2021-01-28 06:00:49
问题 We are trying to abort scenario if there is a failure with specific error response caused by another team's code. Case example for this is that we want to abort the test if we received error errors: [message: 'Data is not deployed....Etc etc'] We know that we can use karate.abort(), however on the documentation we only see example based on status code: * if (responseStatus == 404) karate.abort() I wonder if it is possible for us to do something like * if (response.errors[0].message contains

How can you change all appearances of a text response in Karate DSL without having a placeholder?

那年仲夏 提交于 2021-01-28 06:00:18
问题 I am wondering if it is possible to change all occurrences of a text in a Json response from a Karate DSL text without having a placeholder. For example , the fragment "https://thisisthepart.tochange" appears many times in the json response of karate dsl. I cannot do it with "set" because i do not know for which keys is going to appear that text. "imageUrl": ["https://thisisthepart.tochange/idontwannachange/thispart"] Thanks in advance 回答1: Yes, convert to a string, use the Java API String

Using Karate as Library to my Java @Tests

可紊 提交于 2021-01-28 05:30:16
问题 The best way using karate is with Karate DSL in feature files. However I just wants to check if I can utilize karate as a library to my java based framework. For example I know I can use below code and automate Chrome using Chrome DevTools. public class Test { public static void main(String[] args) { Chrome chrome = Chrome.startHeadless(); chrome.setLocation("https://github.com/login"); ...... chrome.quit(); } } Can I do similar for com.intuit.karate.driver.WebDriver for automating any

DRY or DAMP - Which one is efficient in API automation test scripts?

a 夏天 提交于 2021-01-28 05:05:06
问题 I am currently writing REST API automation test scripts. As most of the research article suggests that we should write DAMP (Descriptive And Meaningful Phrases) tests that promote readability. However, I feel that there are a lot of duplicate codes in my tests and in an attempt to remove the duplicates I end up with ' DRY ' (Don't repeat yourself) code which tends to dependency tests. So I am a bit confused about which approach to use? I would really appreciate it If anyone can give me some

DRY or DAMP - Which one is efficient in API automation test scripts?

不问归期 提交于 2021-01-28 04:59:34
问题 I am currently writing REST API automation test scripts. As most of the research article suggests that we should write DAMP (Descriptive And Meaningful Phrases) tests that promote readability. However, I feel that there are a lot of duplicate codes in my tests and in an attempt to remove the duplicates I end up with ' DRY ' (Don't repeat yourself) code which tends to dependency tests. So I am a bit confused about which approach to use? I would really appreciate it If anyone can give me some

Karate : How to use response of scenario in afterScenario

陌路散爱 提交于 2021-01-28 04:50:49
问题 What is the best way to use the response of scenario in afterScenario?? Background: * configure afterScenario = function(response){if(response.key){ karate.log('key is present');} else{karate.log('key is not present');} } Scenario: get all users Given path 'users' When method get Then status 200 回答1: Try function without input params * configure afterScenario = function(){if(response.key){ karate.log('key is present');} else{karate.log('key is not present');} } if the response variable

Karate Repeat API Call

淺唱寂寞╮ 提交于 2021-01-28 01:24:05
问题 We're using Karate for backend testing of a microservice. I'd like to be able to make N calls to the backend API, where N is configurable as a number without having to do ugly things. This was my first approach: Given url baseUrl And headers HEADERS When method get Then status 200 Given url baseUrl And headers HEADERS When method get Then status 200 Given url baseUrl And headers HEADERS When method get Then status 200 (Just repeating the call) It works, but obviously does not scale well

Karate 0.9.5 : Can't get command line options in parallel execution

放肆的年华 提交于 2021-01-28 00:34:08
问题 I am trying to update my project to the last karate release 0.9.5. All works fine except the parallel execution. It doesn't take in account the tags I run using the command line "-Dkarate.options". This is my TestParallel java class: public class QaaTestParallel { @Test public void testParallel() { Results results = Runner.path("classpath:e2e").parallel(2); generateReport(results.getReportDir()); assertTrue(results.getErrorMessages(), results.getFailCount() == 0); } public static void

How to set big cookie header in karate

时光怂恿深爱的人放手 提交于 2021-01-27 21:51:50
问题 As part of our automation we need to send very huge cookie header to the api. cookie is as below cookie: _ga=GA1.2.1041556506.1557744563; _gcl_au=1.1.139136457.1560512273; JabmoSP0id.ffef=d37c42bf-f223-43c6-a73c-fa502e23712d.1560512274.5.1561197329.1560589232.2561e1f4-79fe-4b63-88c6-157c6e8ed125; _gid=GA1.2.1289186220.1561356841; intercom-session-pk0ds0sg=TlZDS2xJQ3BjdldKQ3QzVkt2U1VkUUJ0WmhsVDBpaTY0YThBR0M0Y0dFMWs1azkwUlBlTWpUbWp1ZHN6MUtydS0tZm5CSlZYU0VPQnVJS1k1aFM2dkxkdz09-

How to set sauce-labs job result as pass or fail using karate?

♀尐吖头ヾ 提交于 2021-01-27 18:54:57
问题 I'm trying to run a simple test scenario on sauce-labs, but the issue is that sauce-labs doesn't identify the test-status as passed or failed on its own. I've gone through multiple solutions but couldn't make any of them work. I would love to know if we can do something in the feature file rather than doing something externally if possible. Following are my feature and java files. Feature File Java File Any help will be appreciated. I'm a JAVA newbie & just starting on the Karate Framework