karate

The best conditional logic for match and match each case

瘦欲@ 提交于 2021-01-28 22:49:18
问题 so, I want to use conditional logic in my code, which the condition is when I got response.response_code == '00' so it will run And match response == res_3[0] And match each response.data.bills == res_3[1] And if response.response_code != '00' , it will run And match response == res_3 And match each response.data.bills == res_3 so, what is the best conditional logic for this case ?? 回答1: Read the docs please: https://github.com/intuit/karate#conditional-logic Use a second feature file: * eval

Karate Software - how to press button where header has specific value (not in direct path)

别说谁变了你拦得住时间么 提交于 2021-01-28 22:38:36
问题 I have task when I want to press button with "Delete" caption according to string (picture attached). There are many these sections in application and I want to press the Delete button according to specific H6 string. I need to write click action to find the code with H6 value (this time "app111") and click on the button Delete. I have tried something like this "rightOf('app111').find('button').click() or below('app111').find('button').click()" in many variations but I was not successful. In

Object.keys and hsOwnProperty js functions are not working in Karate version 0.9.5

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 21:09:30
问题 Previously i was using karate version 0.8.0. After migrating to 0.9.5 all of my functions where i am using Object.keys and hasOwnProperty starts giving me error TypeError: available.hasOwnProperty is not a function . In above code available = { "123": { "57": 2 } } 回答1: Yes these are not supported, as a general rule - use JS only for logic, we don't even advise using JS for loops: https://github.com/intuit/karate#loops Please use the karate.keysOf() instead, and there are many more similar

Running karate tests on chrome with chromedriver inside docker

为君一笑 提交于 2021-01-28 21:07:17
问题 I would like to run my karate tests using the chromedriver and chrome present in a docker container. How can this be achieved ? I could only find the documentation on the native version of chrome here 回答1: We only support chrome native via Docker. Note that you can use existing Selenium "Grid" infra, for e.g see these: https://github.com/ptrthomas/karate-devicefarm-demo https://stackoverflow.com/a/60992292/143475 You can consider creating your own Docker image (which is very common) or use an

Extract Javascript from html response in karate

試著忘記壹切 提交于 2021-01-28 20:39:27
问题 I need help here. I have a POST request which returns response with a HTML response and this HTML response contains javascript inside it. I need to extract text/javascript where it says checkout = {"TransactionID""} .. and pass it as a body in the new POST Request using Karate. I think I need to write javascript function inside the karate feature file, however, I am not able to import libraries etc. <!DOCTYPE html> <html lang="en"> <head> <title> ABC test</title> <meta charset="utf-8"> <meta

Running karate tests on chrome with chromedriver inside docker

我只是一个虾纸丫 提交于 2021-01-28 20:27:56
问题 I would like to run my karate tests using the chromedriver and chrome present in a docker container. How can this be achieved ? I could only find the documentation on the native version of chrome here 回答1: We only support chrome native via Docker. Note that you can use existing Selenium "Grid" infra, for e.g see these: https://github.com/ptrthomas/karate-devicefarm-demo https://stackoverflow.com/a/60992292/143475 You can consider creating your own Docker image (which is very common) or use an

How to retrieve raw request contents before making a REST call in Karate DSL?

孤人 提交于 2021-01-28 20:19:56
问题 I am basically trying to generate AWS signature in order to use them for Authorization. We have third party java libraries (uk.co.lucasweb.aws.v4.signer) to generate this AWS signature. Using the concept of Java Interop, I would be able to call them and retrieve the signature. But I will have to pass all the request details (url, header, param) in the arguments in order to generate it. (getSignature() is a custom java method which was written using the prescribed library) getSignature()

Object.keys and hsOwnProperty js functions are not working in Karate version 0.9.5

核能气质少年 提交于 2021-01-28 20:00:50
问题 Previously i was using karate version 0.8.0. After migrating to 0.9.5 all of my functions where i am using Object.keys and hasOwnProperty starts giving me error TypeError: available.hasOwnProperty is not a function . In above code available = { "123": { "57": 2 } } 回答1: Yes these are not supported, as a general rule - use JS only for logic, we don't even advise using JS for loops: https://github.com/intuit/karate#loops Please use the karate.keysOf() instead, and there are many more similar

Karate check if xml request contains specific value

﹥>﹥吖頭↗ 提交于 2021-01-28 18:43:04
问题 My Karate mock server will accept request in XML form, below is the example of the request: <methodCall> <methodName>MyMethod</methodName> <params> <param> <value> <struct> <member> <name>a</name> <value>abc</value> </member> <member> <name>b</name> <value><i4>2</i4></value> </member> </struct> </value> </param> </params> Within the <struct> , it might have multiple <member> tag. How can I check if within the request <member> , there is specific <name> is presented with specific <value> ? I

Karate check if xml request contains specific value

安稳与你 提交于 2021-01-28 18:40:43
问题 My Karate mock server will accept request in XML form, below is the example of the request: <methodCall> <methodName>MyMethod</methodName> <params> <param> <value> <struct> <member> <name>a</name> <value>abc</value> </member> <member> <name>b</name> <value><i4>2</i4></value> </member> </struct> </value> </param> </params> Within the <struct> , it might have multiple <member> tag. How can I check if within the request <member> , there is specific <name> is presented with specific <value> ? I