-1

我想自动化 web api 测试,但我是自动化的初学者。我有想要自动化的 REST API 列表。有人可以建议我应该从哪里开始吗?我可以使用 Selenium 来实现自动化吗?

4

2 回答 2

2

您可以使用 postman 编写测试用例并测试您的所有 Web api。

比如测试响应时间、状态码、内容类型等等。

这是一个简单的例子。在邮递员的测试选项卡中输入这个。

var contentTypeHeaderExists = responseHeaders.hasOwnProperty("Content-Type");

tests["Has Content-Type"] = contentTypeHeaderExists;

if (contentTypeHeaderExists) {
    tests["Content-Type is application/json"] = 
      responseHeaders["Content-Type"].has("application/json");
}

高级用例包括按模块类型对不同类型的 API 进行分组和保存。

有关更多详细信息,请查看此博客

于 2017-01-18T12:53:49.107 回答
1

You can use any of the external libraries out there to automate the REST APIS. Below are few of them you can use:-

  1. REST Assured Library
  2. HTTP Client

Once you are done with the API Automation using external libraries you can club the same with Selenium to develop Integration Tests which will perform some work on FrontEnd using Selenium library and it can also perform some Backend work using any of the aforesaid clients.

于 2016-06-28T09:30:05.700 回答