从最后一个场景响应调用提交失败,空手道(Invoke filed from last scenari

2019-09-30 19:14发布

下面是我的代码,我想用CartItemId从作为请求scenario2 scenario1响应,但情况不能得到它的价值。

    Scenario: /api/wishlist/item/add - add to wishlist 
     Given path '/api/wishlist/item/add' 
     And headers allHeaders.HeadersToken
     And request {"CultureCode":"CHS","IsSpecificSku":0,"MerchantId":"#(data.StyleMerchantId)","SkuId":"#(data.SkuId)","UserKey":"#(data.UserKey)"}
     When method POST
     Then status 200
     * def CartItemId = response.CartItems[0].CartItemId
     * print CartItemId
     * print response

    Scenario: /api/wishlist/item/remove - remove from wishlist 
     Given path '/api/wishlist/item/remove' 
     And headers allHeaders.HeadersToken
     And request {"CartItemId":"#(CartItemId)","CultureCode":"CHS","UserKey":"#(data.UserKey)"}
     When method POST
     Then status 200

Answer 1:

您正在试图测试“流”在这里,这是“先加,然后删除”。 请结合这两种Scenario s转换之一。

这里详细的解答: https://stackoverflow.com/a/46080568/143475



文章来源: Invoke filed from last scenario response failed with karate
标签: karate