• <small id='5Tu5Y'></small><noframes id='5Tu5Y'>

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

          <bdo id='5Tu5Y'></bdo><ul id='5Tu5Y'></ul>

        <legend id='5Tu5Y'><style id='5Tu5Y'><dir id='5Tu5Y'><q id='5Tu5Y'></q></dir></style></legend>
        <tfoot id='5Tu5Y'></tfoot>

        PHPUnit + Selenium 2:对 ajax 加载的操作

        PHPUnit + Selenium 2: Action on ajax load(PHPUnit + Selenium 2:对 ajax 加载的操作)
          <tbody id='SJFBQ'></tbody>
            <i id='SJFBQ'><tr id='SJFBQ'><dt id='SJFBQ'><q id='SJFBQ'><span id='SJFBQ'><b id='SJFBQ'><form id='SJFBQ'><ins id='SJFBQ'></ins><ul id='SJFBQ'></ul><sub id='SJFBQ'></sub></form><legend id='SJFBQ'></legend><bdo id='SJFBQ'><pre id='SJFBQ'><center id='SJFBQ'></center></pre></bdo></b><th id='SJFBQ'></th></span></q></dt></tr></i><div id='SJFBQ'><tfoot id='SJFBQ'></tfoot><dl id='SJFBQ'><fieldset id='SJFBQ'></fieldset></dl></div>

                <bdo id='SJFBQ'></bdo><ul id='SJFBQ'></ul>
                <tfoot id='SJFBQ'></tfoot>

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

                1. <legend id='SJFBQ'><style id='SJFBQ'><dir id='SJFBQ'><q id='SJFBQ'></q></dir></style></legend>
                2. 本文介绍了PHPUnit + Selenium 2:对 ajax 加载的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  在测试期间我需要做以下事情:

                  During test I need to do following:

                  • 单击按钮会导致 ajax 请求并在此之后重定向
                  • 检查用户是否被重定向到正确的页面

                  我的代码:

                  $this->byId('reg_email')->value('test@example.com');
                  $this->byId('reg_password')->value('seecret');
                  // No form here, so i can't just call submit()
                  // This click invokes ajax request
                  $this->byId('reg_submit')->click();
                  
                  // Check page content (this page should appear after redirect)
                  $msg = $this->byCssSelector('h1')->text();
                  $this->assertEquals('Welcome!', $msg);
                  

                  问题

                  • 消息检查在点击后立即进行,而不是在 ajax 请求和页面重定向之前进行

                  解决办法,我不喜欢:

                  • 在内容检查前添加sleep(3);.

                  我不喜欢它,因为:

                  • 真傻
                  • 如果响应速度很快,我会浪费时间,如果请求很长,我会在 ajax 请求完成之前进行内容检查.

                  我想知道,有没有什么方法可以跟踪 ajax 请求+刷新并及时检查内容?

                  I wonder, is there any way to track ajax request+refresh and check for content just in time?

                  我的设置:

                  • PHP 5.4、5.5 也可用
                  • PHPUnit 3.8
                  • 用于 PHPUnit 1.3.1 的 Selenium RC 集成
                  • Selenium-server-standalone 2.33.0
                  • Windows 7 x64
                  • JRE 7

                  推荐答案

                  好吧,有一种解决方案,我不是很喜欢它,但它是有的而不是无.

                  Ok, there is a kind of solution, I do not really like it, but it is something instead of nothing.

                  这个想法是使用更智能的睡眠",有一个方法 waitUntil() 采用 anonymous functiontimeout in毫秒.什么是 - 在循环中运行这个传递的函数,直到超时或你的函数返回 True.所以你可以运行一些东西并等到上下文改变:

                  The idea is to use more smart "sleep", there is a method waitUntil() which takes an anonymous function and timeout in milliseconds. What is does - runs this passed function in loop until timeout hits or your function return True. So you can run something and wait until context is changed:

                  $this->waitUntil(function () {
                      if ($this->byCssSelector('h1')) {
                          return true;
                      }
                      return null;
                  }, 5000);
                  

                  如果有人提供更好的解决方案,我仍然会很高兴.

                  I still will be glad if somebody give better solution.

                  这篇关于PHPUnit + Selenium 2:对 ajax 加载的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

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

                      <tfoot id='iauGV'></tfoot>
                        <bdo id='iauGV'></bdo><ul id='iauGV'></ul>
                      • <legend id='iauGV'><style id='iauGV'><dir id='iauGV'><q id='iauGV'></q></dir></style></legend>
                          <tbody id='iauGV'></tbody>