空手道API-为什么响应未返回被调用的特征文件 [英] Karate API - Why response in not returning to called feature file
本文介绍了空手道API-为什么响应未返回被调用的特征文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过传递un,pwd和端点url,从后台标签下的另一个功能中调用登录功能,如下所示.登录功能正在成功运行,但是其响应不会返回到被调用的功能文件中.
I am calling login feature from another feature under background tag by passing un, pwd and endpoint url like below. Login feature is running successfully but the response of it is not returned to called feature file.
@Add
Feature: Adding products
Background:
* table loginDetails
| username | password | endPointURL |
| 'kUser' | 'kPass' | 'https://qa1.com/shop/login/login' |
* def result = call read('Login.feature') loginDetails
* print 'Result-'+response
* print 'Result-'+result.response
@loginTest
Scenario: running @loginTest from runner file
* print 'Login response -'+result.responseCookies
这就是我的回应.
13:08:53.470 [main] INFO com.intuit.karate - [print] {
"redirect": false,
"loginSuccess": true,
"redirectUrl": ""
}
13:08:53.519 [main] INFO com.intuit.karate - [print]
13:08:53.546 [main] INFO com.intuit.karate - [print] RUResult-undefined
13:08:53.547 [main] INFO com.intuit.karate - [print] Login response -undefined
推荐答案
当您将数据表/JSON数组传递给被调用的功能时,您将获得JSON数组作为回报.
When you pass a data table/ JSON array to the called feature you will get JSON array in return.
result
对象将具有类似于数据的JSON数组/列表,因此您必须相应地读取该变量
Here result
object will have JSON array/list like data, so you have to read that variable accordingly
对于上述示例,
* print result[0].response
* print result[0].responseCookies
这篇关于空手道API-为什么响应未返回被调用的特征文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文