• <bdo id='DXEvN'></bdo><ul id='DXEvN'></ul>

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

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

      <tfoot id='DXEvN'></tfoot>
      <i id='DXEvN'><tr id='DXEvN'><dt id='DXEvN'><q id='DXEvN'><span id='DXEvN'><b id='DXEvN'><form id='DXEvN'><ins id='DXEvN'></ins><ul id='DXEvN'></ul><sub id='DXEvN'></sub></form><legend id='DXEvN'></legend><bdo id='DXEvN'><pre id='DXEvN'><center id='DXEvN'></center></pre></bdo></b><th id='DXEvN'></th></span></q></dt></tr></i><div id='DXEvN'><tfoot id='DXEvN'></tfoot><dl id='DXEvN'><fieldset id='DXEvN'></fieldset></dl></div>
      1. 在警报上单击“确定"或通过 jquery/javascript 确

        时间:2023-09-06
        1. <small id='jorF2'></small><noframes id='jorF2'>

          <tfoot id='jorF2'></tfoot>

          <legend id='jorF2'><style id='jorF2'><dir id='jorF2'><q id='jorF2'></q></dir></style></legend>

            <i id='jorF2'><tr id='jorF2'><dt id='jorF2'><q id='jorF2'><span id='jorF2'><b id='jorF2'><form id='jorF2'><ins id='jorF2'></ins><ul id='jorF2'></ul><sub id='jorF2'></sub></form><legend id='jorF2'></legend><bdo id='jorF2'><pre id='jorF2'><center id='jorF2'></center></pre></bdo></b><th id='jorF2'></th></span></q></dt></tr></i><div id='jorF2'><tfoot id='jorF2'></tfoot><dl id='jorF2'><fieldset id='jorF2'></fieldset></dl></div>
                  <tbody id='jorF2'></tbody>
                  <bdo id='jorF2'></bdo><ul id='jorF2'></ul>
                  本文介绍了在警报上单击“确定"或通过 jquery/javascript 确认对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在考虑用backbone.js 和jquery 编写一些UI 测试.它们可能不是最好的方法,但这是我正在考虑的事情 - 通过纯代码自动化测试而无需记录和回放.

                  I was thinking of writing some UI tests in backbone.js and jquery. They may not be the best way to do it but it's something that I was thinking about - to automate the tests without record and playback - through plain code.

                  使用这种方法唯一让我摸不着头脑的是:在某些用例流程"(执行)中会出现确认/警报对话框.我想单击确定"并继续流程 - 这甚至可以通过纯 JavaScript 代码实现吗?怎么样?

                  The only thing that made me scratch my head using this approach is this: In some 'use-case flow' (of the execution) confirm/alert dialogs would show up. I'd like to click 'Ok' and continue the flow - is this even doable through plain javascript code? How?

                  注意:我确实知道存在 GUI 测试库,但我想知道如何仅使用 jQuery/javascript 代码来完成它,如果可能的话.

                  Note: I do know GUI testing libraries exist, but I want to know how to do it using just jQuery/javascript code, if at all possible.

                  推荐答案

                  据我所知,如果您使用标准的 alert() 调用,则无法触发确定"点击,因为警报调用阻塞正常的 JS 事件循环.

                  As far as I know if you use a standard alert() call you cannot trigger an "OK" click because the alert call blocks the normal JS event loop.

                  但是您应该能够将 window.alertwindow.confirm 替换为您自己的不执行任何操作的函数:

                  However you should be able to replace window.alert and window.confirm with your own function that does nothing:

                  window.alert = function() {
                      console.log.apply(console, arguments);
                  };
                  

                  在加载其他任何内容之前将它们放在 JS 的顶部,随后对 alert()confirm() 的任何调用都会改为调用它们.

                  Place these at the top of your JS before anything else is loaded and any subsequent calls to alert() or confirm() will call these instead.

                  这篇关于在警报上单击“确定"或通过 jquery/javascript 确认对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:QunitJS-Tests 不启动:PhantomJS 超时,可能是由于缺少 下一篇:PhantomJS 并单击表单按钮

                  相关文章

                  最新文章

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

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

                  <legend id='tF9E8'><style id='tF9E8'><dir id='tF9E8'><q id='tF9E8'></q></dir></style></legend>

                  1. <tfoot id='tF9E8'></tfoot>