简体   繁体   English

如何将参数传递给Selenium Java测试文件中的空手道特征文件

[英]How to pass arguments to karate feature file from selenium java test file

I want to pass an argument to karate graphql test from selenium java test. 我想将参数传递给硒java测试的空手道graphql测试。 I tried to do that this way, but it didn't work. 我尝试过这种方式,但是没有用。

HashMap<String, Object> args = new HashMap<String, Object>();
args.put("argument1", "value1");
Map<String, Object> result = CucumberRunner.runFeature(featureFile, 
args, true);

I tried to put that value in karate file in ways like 我试图以类似的方式将该值放入空手道文件中

<argument1>

or 要么

#(argument1)

but literally this text was passed to query in karate test. 但是从字面上看,这段文字是通过空手道测试传递给查询的。 Have someone done that by karate? 有人用空手道做到了吗?

Here you have fragment of my feature file: 这是我功能文件的片段:

Given text query =
"""
{
  element(name:"<argument1>") {
    name
  }
}
"""
And request {query: '#(query)'}
When method post
Then status 200
* print response

I think you missed a replace , try this: 我认为您错过了replace ,请尝试以下操作:

Given text query =
"""
{
  element(name:"<argument1>") {
    name
  }
}
"""
And replace query.argument1 = argument1
And request {query: '#(query)'}
When method post
Then status 200

暂无
暂无

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

相关问题 空手道功能文件 + 调用 Java class 和 spring 注释,得到 PolyglotException - Karate feature file + calling Java class with spring annotations, getting PolyglotException 我如何使用 1 个参数在空手道功能文件中调用 js function - How can i call the js function in karate feature file with 1 argument 使用Selenium和Java的文件上传功能 - File Upload Feature using Selenium and java 如何使用java Cucumber将“#”作为特征文件中的有效参数传递 - How to pass "#" as a valid parameter in feature file using java cucumber 如何从属性文件获取文件路径并将其作为参数传递给方法 - How get file path from property file and pass into the method as arguments 如何将一个特征文件的数据(从示例中)传递到另一个特征文件? - how to pass the data(from Examples) of one feature file to other feature file? java - 如何从文本文件中读取数据并将它们作为参数化测试传递给junit测试? - how to read data from text file and pass them to junit test as parameterized test in java? 如何在Java中使用ProcessBuilder将文件路径作为参数传递 - How to pass file path as arguments using ProcessBuilder in Java 如何在批处理文件中传递java -jar参数? - How can I pass java -jar arguments in a batch file? 如何测试或模拟使用Java在Selenium Webdriver中将文件从桌面拖动到浏览器 - How to test or simulate draging a file from desktop to browser in selenium webdriver using Java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM