<small id='LBK21'></small><noframes id='LBK21'>

  • <legend id='LBK21'><style id='LBK21'><dir id='LBK21'><q id='LBK21'></q></dir></style></legend>

  • <tfoot id='LBK21'></tfoot>

    • <bdo id='LBK21'></bdo><ul id='LBK21'></ul>
      1. <i id='LBK21'><tr id='LBK21'><dt id='LBK21'><q id='LBK21'><span id='LBK21'><b id='LBK21'><form id='LBK21'><ins id='LBK21'></ins><ul id='LBK21'></ul><sub id='LBK21'></sub></form><legend id='LBK21'></legend><bdo id='LBK21'><pre id='LBK21'><center id='LBK21'></center></pre></bdo></b><th id='LBK21'></th></span></q></dt></tr></i><div id='LBK21'><tfoot id='LBK21'></tfoot><dl id='LBK21'><fieldset id='LBK21'></fieldset></dl></div>

        如何从量角器测试发出 POST 请求?

        时间:2023-06-15
        <tfoot id='HccND'></tfoot>

            <tbody id='HccND'></tbody>
              • <bdo id='HccND'></bdo><ul id='HccND'></ul>
              • <small id='HccND'></small><noframes id='HccND'>

                <legend id='HccND'><style id='HccND'><dir id='HccND'><q id='HccND'></q></dir></style></legend>
                <i id='HccND'><tr id='HccND'><dt id='HccND'><q id='HccND'><span id='HccND'><b id='HccND'><form id='HccND'><ins id='HccND'></ins><ul id='HccND'></ul><sub id='HccND'></sub></form><legend id='HccND'></legend><bdo id='HccND'><pre id='HccND'><center id='HccND'></center></pre></bdo></b><th id='HccND'></th></span></q></dt></tr></i><div id='HccND'><tfoot id='HccND'></tfoot><dl id='HccND'><fieldset id='HccND'></fieldset></dl></div>

                  本文介绍了如何从量角器测试发出 POST 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想在运行 Protractor 测试之前向数据库服务器发出 POST 请求(带有 JSON 有效负载),在为了注入测试数据.如果可能的话,我该怎么做?

                  I would like to make a POST request (with JSON payload) to a database server prior to running a Protractor test, in order to inject test data. How can I do this, if at all possible?

                  推荐答案

                  在 Andres D 的帮助下,我找到了一种方法.它的要点是通过 browser 在浏览器中运行脚本.执行AsyncScript 并在其中注入 $http 服务.然后告诉 $http 服务发出 POST 请求.这是如何完成的示例 CoffeeScript:

                  I found a way to do it, with the help of Andres D. The gist of it is to run a script in the browser via browser.executeAsyncScript and inject the $http service in there. The $http service is then told to make a POST request. Here's example CoffeeScript of how it's done:

                  browser.get('http://your-angular-app.com')
                  browser.executeAsyncScript((callback) ->
                    $http = angular.injector(["ng"]).get("$http")
                    $http(
                      url: "http://yourservice.com"
                      method: "post"
                      data: yourData
                      dataType: "json"
                    )
                    .success(->
                      callback([true])
                    ).error((data, status) ->
                      callback([false, data, status])
                    )
                  )
                  .then((data) ->
                    [success, response] = data
                    if success
                      console.log("Browser async finished without errors")
                    else
                      console.log("Browser async finished with errors", response)
                  )
                  

                  这篇关于如何从量角器测试发出 POST 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:量角器测试:如何设置登录表单中文本元素的值? 下一篇:如何让量角器按回车键?

                  相关文章

                    <legend id='Kc0XL'><style id='Kc0XL'><dir id='Kc0XL'><q id='Kc0XL'></q></dir></style></legend><tfoot id='Kc0XL'></tfoot>

                      <bdo id='Kc0XL'></bdo><ul id='Kc0XL'></ul>
                    <i id='Kc0XL'><tr id='Kc0XL'><dt id='Kc0XL'><q id='Kc0XL'><span id='Kc0XL'><b id='Kc0XL'><form id='Kc0XL'><ins id='Kc0XL'></ins><ul id='Kc0XL'></ul><sub id='Kc0XL'></sub></form><legend id='Kc0XL'></legend><bdo id='Kc0XL'><pre id='Kc0XL'><center id='Kc0XL'></center></pre></bdo></b><th id='Kc0XL'></th></span></q></dt></tr></i><div id='Kc0XL'><tfoot id='Kc0XL'></tfoot><dl id='Kc0XL'><fieldset id='Kc0XL'></fieldset></dl></div>
                    1. <small id='Kc0XL'></small><noframes id='Kc0XL'>