jQuery的AJAX的成功没有得到触发与codeD UI测试项目 [英] Jquery AJAX success not getting triggered with Coded UI test project

查看:103
本文介绍了jQuery的AJAX的成功没有得到触发与codeD UI测试项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图运行一个asp.net MVC4应用codeD-UI测试项目。
该应用程序包含各种涉及Ajax调用。
当我手动测试它,它工作正常,但是当我用codeD-UI测试项目来测试它,
它打破因为在Ajax调用,回调函数不会被调用。
谁能告诉我我失去了什么来?
先谢谢了。

I am trying to run a Coded-UI test project on a asp.net MVC4 application. The application contains various ajax calls involved. When i test it manually,it works fine but when i test it by using coded-ui test project, it breaks because in the ajax calls,the callback function does not get called. Can anybody tell me what am i missing here.? Thanks in advance.

推荐答案

什么错

微软codeD UI浏览器的JavaScript注入到垫片用于跟踪XMLHtt prequest对象。在页面的任何Ajax调用将使用此垫片而不是真正的XMLHtt prequest的。垫片假设你完成回调附着到XMLHtt prequest的onreadystatechange属性,但jQuery的2.0使用新的onload和的onerror事件,所以回调从不由垫片称为

Microsoft's Coded UI browser injects javascript to shim the XMLHttpRequest object for tracking. Any ajax calls in the page will use this shim instead of the real XMLHttpRequest. The shim assumes that your completion callback is attached to the XMLHttpRequest's onreadystatechange property, but jQuery 2.0 uses the new onload and onerror events, so the callback is never called by the shim.

解决方法

的变通方法是添加下面为您的测试项目App.config文件:

The work-around is to add the following to the App.config file for your test project:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="WebWaitForReadyLevel" value="3"/>
  </appSettings>
</configuration>

设置WebWaitForReadyLevel 3从注入的JavaScript来跟踪Ajax调用和计时器停止codeD UI web浏览器。 jQuery将得到一个真正的XMLHtt prequest,你的AJAX回调将再次合作。

Setting WebWaitForReadyLevel to 3 stops the Coded UI WebBrowser from injecting the javascript to track ajax calls and timers. jQuery will get a real XMLHttpRequest, and your ajax callbacks will work again.

这篇关于jQuery的AJAX的成功没有得到触发与codeD UI测试项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆