【发布时间】:2020-03-29 09:37:10
【问题描述】:
我需要帮助来了解如何使用 cy.route() 和 cy.wait() 来检查结果下面三个 API 调用中的每一个是否为 200 或说成功。
HTTP 地址
请求网址:https://......../ABC 请求方法:POST 状态码:200 OK
请求有效负载 - 根据该值,我看到三个 API 调用使用上述 Http 请求,如下所示
{CountryCode: "USA", countryRatingType: "A"}
{CountryCode: "USA", countryRatingType: "B"}
{CountryCode: "USA", countryRatingType: "C"}
在上述三个 API 调用中,countryRatingType 对于各自的 API 保持静态,但国家代码值会根据输入发生变化
假设我选择 CAN 作为国家/地区
{CountryCode: "CAN", countryRatingType: "A"}
{CountryCode: "CAN", countryRatingType: "B"}
{CountryCode: "CAN", countryRatingType: "C"}
【问题讨论】:
-
3 个 API 调用使用相同的 url 和不同的请求?
-
没错。
-
我今天在玩,并且能够找到解决方案。我使用了“expect(xhr.requestBody).includes({ countryCode: CAN, countryRatingType: "A" })”,它成功了。后来我用夹具替换了 CAN 以使其动态
标签: cypress