天道酬勤,学无止境

web-api-testing

REST API Testing: How to get response using Google Chrome developer tools?

I'm very new to API testing. I'm trying to make use of Google Chrome's developer tools to understand and explore this subject. Question 1: Is it possible to get the response (possibly in JSON format) of a simple GET request using chrome developer tools? What I'm currently doing is: Open chrome developer tools Go to Network tab Clear existing logs Send a post request simply by hitting a URL. e.g. https://stackoverflow.com/questions/ask Check the corresponding docs loaded Question 2: What are the relevance "Reponse Headers" shown on the image above? I mean, am I correct to think that this is the

2021-11-24 21:25:22    分类:问答    rest   google-chrome   google-chrome-devtools   web-api-testing   chrome-dev-editor

如何使用空手道使用给定的 XML 验证 SOAP 服务 XML 文件(How to validate SOAP service XML file with given XML using Karate)

问题 我正在学习用于执行我们基于 SOAP 的 Web 服务的空手道 API 。 为此,我创建了两个 XML 文件,其中一个是请求信息,另一个是响应数据。 然后我又创建了一个名为webservice.feature文件的文件。 当我执行此功能文件时,我在控制台中收到以下信息,但我不明白,也不知道如何验证。 请提出您的建议。 webservice.feature 文件: Feature: Get Membership Details Background: * url 'http://111.111.221.145:2201/Customer/ProxyServices/CustomerSummary_PS?wsdl' Scenario: FunctionalTest Given request read('getMbrWksMembershipSummaryRequest.xml') And header Content-Type = 'application/soap+xml; charset=utf-8' When method post Then status 200 And match response customerSummary/address/city == read('getMbrWksMembershipSummaryResponse.xml') And

2021-11-23 10:37:14    分类:技术分享    selenium   automation   cucumber   web-api-testing   karate

如何从 Excel 电子表格中读取输入数据并将其传递给空手道框架中的 JSON 有效负载?(How to read input data from an excel spreadsheet and pass it JSON payload in karate framework?)

问题 我需要为空手道框架中的不同 API 创建数据驱动的单元测试。 要在 JSON 有效负载中传递的各种元素应作为来自 excel 文件的输入。 回答1 几点: 我建议您查看 Karate 的内置数据表功能,它更具可读性,集成到您的测试脚本中,您无需依赖其他软件。 请参阅这些示例:call-table.feature 和 dynamic-params.feature 接下来我建议使用 JSON 而不是 Excel 或 CSV 文件,它由 Karate 本身支持:call-json-array.feature 最后,如果您真的愿意,您可以调用任何 Java 代码,如果您以Map / List形式返回数据,它就可以供空手道使用了。 此示例显示如何通过 JDBC 读取数据库:dogs.feature。 因此,虽然这不是内置在 Karate 中,但只需编写一个简单的实用程序来读取 CSV 或 Excel 文件,您就可以做几乎任何 Java 可以做的事情。 编辑:空手道现在支持 CSV 文件,甚至可以用来进行数据驱动测试:https://github.com/intuit/karate#csv-files

2021-11-23 10:35:58    分类:技术分享    cucumber   bdd   rest-assured   web-api-testing   karate

如何在 POSTMAN 环境中添加授权头?(How to add authorization header in POSTMAN environment?)

问题 我正在使用 POSTMAN 测试一堆 API 调用。 我可以将其作为 POSTMAN 环境的一部分,而不是为每个请求添加授权标头吗? 所以,我不必每次请求都传递它。 回答1 是的,您可以通过 Postman 通过将您的标头分配为环境变量来执行此操作,例如authorization ,如下所示: 然后使用其值设置环境变量,如下所示: 回答2 在 Postman 的当代版本中,您只需在集合(或文件夹)上设置您的身份验证,并让每个请求都继承它(我相信默认情况下新请求会这样做)。 回答3 邮递员通常会记住您在标头中发送的键值对。 因此无需为每个请求添加标头。 无论如何,您可以使用您的身份验证令牌配置“预设”。 回答4 如果你迫不及待,这里有一个我刚做的解决方法: 导出您的收藏(数据格式 v2.1) 打开 firefox、开发工具、便笺簿粘贴下面的代码用您的标题替换标题信息将 var a 替换为您导出的 .json 文件的内容运行脚本 copy(b) 命令会将新数据放入剪贴板在邮递员中,单击导入 > 粘贴原始文本 > 导入 > 作为副本。 验证您的请求是否包含标头,然后运行它 :) var myHeader = { "key": "X-Client-DN", "value": "{{Postman-DN}}", "description": "The User's DN

2021-11-22 03:51:46    分类:技术分享    postman   web-api-testing

Visual reporting for Karate without Jenkins CI

I'm trying to get reporting working for Karate DSL, and it's proven a challenge because my team uses Circle CI instead of Jenkins. Cucumber reporting seems to only work for Jenkins. I've had a look at this documentation, here: https://github.com/intuit/karate/tree/master/karate-demo#example-report https://github.com/jenkinsci/cucumber-reports-plugin I was wondering if there is a circle friendly equivalent you could recommend? It'd be even better if the reports could be generated in the terminal. It's going to be a hard sell to convince my team to change CI tools just so I can implement a test

2021-11-18 18:17:12    分类:问答    jenkins   continuous-integration   circleci   web-api-testing   karate

Having a POJO like feature in KarateAPI?

I have been using Karate and RestAssured for sometime. There are advantages and downside of both tools of course. Right now I have a RestAssured project where I have Request and Response object and POJOs. My requests wraps my endpoint and send my POJOs to those endpoint. I do all my Headers, etc configuration in an abstract layer. In case I need to override them, I override them during the test. If not, Its a two lines of code for me to trigger an endpoint. My way of working with happy path and negative path of an edpoint is that I initialize the POJO before every test with new values in the

2021-11-18 17:46:42    分类:问答    rest-assured   karate   web-api-testing

How to add authorization header in POSTMAN environment?

I'm testing bunch of API calls using POSTMAN. Instead of adding authorization header to each request, can I make it as a part of POSTMAN environment? So, I don't have to pass it with every request.

2021-11-15 13:13:27    分类:问答    postman   web-api-testing

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

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.

2021-11-15 07:11:51    分类:问答    cucumber   bdd   rest-assured   web-api-testing   karate

How to validate SOAP service XML file with given XML using Karate

I'm learning Karate API for executing our SOAP-based web services. For that, I have created two XML files in which, one is, request information and another one is response data. And then I have created one more file is called webservice.feature file. When I execute this feature file I'm getting the following information in the Console but I don't understand and also I don't know how to validate that. Please give your suggestions. webservice.feature File: Feature: Get Membership Details Background: * url 'http://111.111.221.145:2201/Customer/ProxyServices/CustomerSummary_PS?wsdl' Scenario

2021-11-13 04:27:48    分类:问答    selenium   automation   cucumber   web-api-testing   karate

模拟外部 API 以使用 Python 进行测试(Mocking external API for testing with Python)

问题 语境 我正在尝试为查询外部 API 的函数编写测试。 这些函数向 API 发送请求,获取响应并处理它们。 在我的测试中,我想使用本地运行的 Mock 服务器来模拟外部 API。 到目前为止,模拟服务器已成功运行并响应自定义 GET 查询。 问题 外部 API 以<class 'dict'>类型的对象进行响应,而显然我能从我的模拟服务器得到的只是<class 'bytes'>类型的响应。 模拟服务器从磁盘获取预定义的数据并通过流返回它们。 由于我无法模拟外部 API,因此我的测试会因为响应类型错误而抛出错误消息。 以下是我的代码片段以及一些解释。 1.设置()函数: setUp 函数在测试套件的开头运行。 它负责在运行测试之前配置和运行服务器: def setUp(self): self.factory = APIRequestFactory() # Configuring the mock server self.mock_server_port = get_free_port() self.mock_server = HTTPServer(('localhost', self.mock_server_port), MockServerRequestHandler) # Run the mock server in a separate thread self.mock

2021-11-10 23:56:01    分类:技术分享    python   json   unit-testing   httpserver   web-api-testing