简体   繁体   English

空手道:将变量从一个特征文件传递到另一个作为查询参数

[英]Karate : Passing variable from one feature file to another as a query parameter

I'm trying to execute a feature file and need which takes a query parameter from another feature.我正在尝试执行一个功能文件,并且需要从另一个功能中获取查询参数。

Here is the feature files : 1. This file call two feature files.下面是特征文件: 1. 这个文件调用了两个特征文件。 First feature file add a record in the database and returns json response.第一个特征文件在数据库中添加一条记录并返回 json 响应。 I have to use a property from the response and have to pass to another feature.我必须使用响应中的属性,并且必须传递给另一个功能。 Please find below for the features files.请在下面找到功能文件。

Feature: Background:特点: 背景:

Scenario: Given call read('test_add.feature')场景:给定调用 read('test_add.feature')

And def query1 = response.name

Given call read('test_get.feature') {'**query**' : #query1}
  1. feature name - test_get.feature Feature: Add a new Nat bundle device功能名称 - test_get.feature 功能:添加新的 Nat 捆绑设备

    Background:背景:

    • url baseUrlWithContext url baseUrlWithContext

    • def headers = { 'Content-Type': 'application/json' } def headers = {'内容类型':'应用程序/json'}

    Scenario: Addition场景:添加

    Given headers headers给定标题标题

    And path '/test'和路径'/test'

    And params query和参数查询

    When method get当方法得到

    Then status 200然后状态 200

Error : com.intuit.karate.exception.KarateException:错误:com.intuit.karate.exception.KarateException:

cannot convert to map: query无法转换为地图:查询

Instead of And params query而不是And params query

Try this:尝试这个:

And param query = query

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在空手道中将变量从一个特征文件传递到另一个特征文件作为请求 URL(不是查询参数)的一部分 - Passing a variable from one feature file into another as a part of request URL(not query parameter) in Karate 空手道 API 测试 - 将变量从一个特征文件传递到另一个 - Karate API Testing - Passing variable from one feature file to another 如何使用空手道 API 测试将变量从一个特征文件调用到另一个特征文件 - How can I call a variable from one feature file to another feature file using Karate API Testing 空手道将 csv 详细信息传递到另一个功能文件 - Karate passing csv details to another feature file 空手道:如果该值不为空,则从一个响应中将值作为查询参数传递 - Karate : passing value as query parameter from one response if that value is not null 在空手道中 - 从另一个特征文件调用的特征文件以及变量值 - In Karate - Feature file calling from another feature file along with variable value 如何传递 karate.prevRequest 和 response 是 arguments 从一个功能文件到另一个功能文件 - How to pass karate.prevRequest and response are the arguments from one feature file to another feature file 如何从一个特征文件表中读取数据并传递值以在空手道的 *.json 文件中设置 json 参数? - How to read data from one feature file table and pass the value to set json parameter in a *.json file in karate? 在一个功能中设置空手道中的全局变量以在另一功能中使用 - Setting global variables in karate from one feature to be used in another feature 在从空手道中的另一个功能中调用场景时传递参数? - Passing parameters while calling a scenario from another feature flie in karate?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM