【问题标题】:how to pass body type in Karate feature file?如何在空手道特征文件中传递体型?
【发布时间】:2020-12-29 09:00:39
【问题描述】:

我是 api 自动化和空手道框架的新手,我被要求使用 Body Type = 'x-www-form-urlencoded' 和其他参数(由于安全限制无法共享)自动执行 GET 请求,我有尝试了以下选项,但收到一条错误消息,指出“没有找到与以下内容匹配的步骤定义方法:Body Content-Type = 'application/x-www-form-urlencoded;charset=utf-8'

以下是我尝试过的.Feature文件内容:

**Feature: First demo API 
  Scenario: API demo try
    Given url '{Given_url}'
    And Body Content-Type = 'application/x-www-form-urlencoded;charset=utf-8' 
    And Body {Grant_type:Value, scope:value}
    when method GET
    Then status 200**

我什至尝试将正文类型传递为“x-www-form-urlencoded;charset”,但仍然遇到同样的问题。请帮助我并提前致谢。

问候, V.Prashanth

【问题讨论】:

    标签: api automation frameworks karate


    【解决方案1】:

    您的语法错误。请阅读文档:https://github.com/intuit/karate#header

    And header Content-Type = 'blah'
    And request { Grant_type: 'Value', scope: 'value' }
    

    【讨论】:

    • 请帮助我解决另一个问题,我正在运行 Json 请求并在传递所需参数时将测试结果设为“通过/失败”,但我无法获得 Json 响应,我进入“邮递员”。你能告诉我有什么原因吗?。
    • 完全不知道。也许你应该坚持使用 Postman ;)
    • 以下是我正在尝试的请求 *功能:第一个演示 API 场景:API 演示尝试给定 url '{Given_url} 和标头 Content-Type = 'blah' 和请求 { Grant_type:' Value', scope: 'value' } when method GET Then status 200 - 这是我作为请求传入的同一个 Json 文件。提前致谢!!请帮忙。
    • 是时候让你遵循这个过程了。祝一切顺利 ! github.com/intuit/karate/wiki/How-to-Submit-an-Issue
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-06
    • 1970-01-01
    • 2018-04-14
    • 1970-01-01
    • 2022-11-08
    • 1970-01-01
    相关资源
    最近更新 更多