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

<tfoot id='jtkWy'></tfoot>

    • <bdo id='jtkWy'></bdo><ul id='jtkWy'></ul>
    1. <legend id='jtkWy'><style id='jtkWy'><dir id='jtkWy'><q id='jtkWy'></q></dir></style></legend>

        <i id='jtkWy'><tr id='jtkWy'><dt id='jtkWy'><q id='jtkWy'><span id='jtkWy'><b id='jtkWy'><form id='jtkWy'><ins id='jtkWy'></ins><ul id='jtkWy'></ul><sub id='jtkWy'></sub></form><legend id='jtkWy'></legend><bdo id='jtkWy'><pre id='jtkWy'><center id='jtkWy'></center></pre></bdo></b><th id='jtkWy'></th></span></q></dt></tr></i><div id='jtkWy'><tfoot id='jtkWy'></tfoot><dl id='jtkWy'><fieldset id='jtkWy'></fieldset></dl></div>
      1. 如何从量角器测试发出 POST 请求?

        时间:2023-10-12

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

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

                1. <legend id='KO5mm'><style id='KO5mm'><dir id='KO5mm'><q id='KO5mm'></q></dir></style></legend>
                  本文介绍了如何从量角器测试发出 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 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

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

                  相关文章

                  最新文章

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

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

                  <tfoot id='ZgH74'></tfoot>

                    1. <legend id='ZgH74'><style id='ZgH74'><dir id='ZgH74'><q id='ZgH74'></q></dir></style></legend>