karate - Karate API : Passing variables to other feature file is not working
问题描述
I am calling login feature file from other feature file from where I am passing url, username and password but it is not working for me. I am not using Background key here and i do not want also.
@CallAnotherFeature
Feature: Call Login Feature
Scenario: Calling Login Test
* def config = { endPointURL: 'https://qa1.testurl.com/login',username: 'user123', password: 'password123' }
* def result= call read('Login.feature') config
* print result.response
* print 'Sign In-'+signIn
* print 'Sign In Reponse-'+signIn.response
Feature: Login Feature
Scenario: Test Login for different users
* print 'Starting Test','#(endPointURL)'
Given url '#(endPointURL)'
* print 'user name','#(username)'
* print 'Password ','#(password)'
#And form field username = '#(username)'
#And form field password = '#(password)'
And request { username: '#(username)', password: '#(password)'}
When method post
Then status 200
* print response
* match response.loginSuccess == true
In Login.feature I tried to pass username and password as form data also even though these did not work. Could someone tell me what mistake I am making here.
I am using latest karate version 0.9.0
解决方案
我在您的脚本中看到了一些问题,
1. 来电登录功能
1.1)我在此功能的任何地方都没有看到signIn
变量初始化,也没有从您那里看到变量,login feature
但您正在尝试打印它。
1.2)=
应正确放置;)
* def result = call read('Login.feature') config
2.登录功能
2.1)我认为您误解了嵌入式表达式的概念。仅用于将其模板化为 JSON,您可以使用它。但是要调用它,您可以简单地使用变量名。
例如。
Given url endPointURL
And form field username = username
And request { username: '#(username)', password: '#(password)'}
不是
Given url '#(endPointURL)'
And form field username = '#(username)'
推荐阅读
- javascript - Vue.js 中的 vue-google-oauth-2 问题
- angular - 了解 Angular 中的作用域
- php - 如何在 Laravel 5.6 中使用和自定义 HTML 电子邮件(不是 markdown)?
- java - Apache Spark 减少操作调用函数的次数比预期的要多
- java - 如何使用接受不同数据类型的spring在kafka中创建两个生产者kafka模板一个是JsonNode,另一个是Avro?
- python - 证书过期,不能与 cerify=True 一起使用;requests.exceptions.SSLError 证书验证失败
- android - AuthenticationCallback 和 KeygenParameterSpec 使应用程序崩溃,尽管检查了 API 级别
- html - 如何使用输入类型=数字在滑块中设置计数?
- python - 按前两个字符对 Python 列表进行排序并返回出现次数较多的字符
- java - 获取一个字符串列表并将数组列表中的每个字符加倍