QTP网络extensibilty工具包和AJAX [英] QTP Web extensibilty toolkit and ajax

查看:197
本文介绍了QTP网络extensibilty工具包和AJAX的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图测试使用QTP的web应用程序正在使用的Ajax4jsf来实现Ajax特性。 QTP没有当AJAX已经完成识别的能力。 我读过,其设置有QTP 9.5和QTP 10的网络可扩展性工具包是我的问题的解决方案。 但是,我不明白这是如何能帮助我:我需要知道HTT prequest对象的就绪状态,并继续测试时的状态为完成。但我不知道如何到达从web可扩展性工具包中的HTT prequest。 任何帮助将是AP preciated。

解决方案

感谢您的回答。

我们还是设法解决使用QTP Extensibilty工具包,我们的问题: A4J使用被唤醒之前和Ajax后(根据收听者的类型)听众的队列。 在我们的解决方案,我们实现了一个JScript函数为每个Ajax组件(如webButton):
1.初始化一个globalVariable为0
2.注册一个新的功能型onafterajax的监听器:

  _elem.ownerDocument.parentWindow.A4J.AJAX.AddListener({
    onafterajax:功能(REQ,事件,数据){
    globalVariable = 1;
    }
    });
 

  1. 按一下按钮
  2. 走进一种忙等待循环:

     而(globalVariable!= 1){
    _util.Wait(250);
    }
     

我们登记的功能,当阿贾克斯完成并改变globalVariable因此while循环将退出被调用。 我知道这是丑陋的,但它的伟大工程。

我们的唯一问题是,QTP 10实现_ut​​il.wait同时QTP 9.5不。无需等待,浏览器将陷入无限循环,注册函数将不会被调用。 任何有关的非忙等待等待在JScript实施的解决方案将是最AP preciated。

I'm trying to test using QTP a web app that is using ajax4jsf to implement the ajax features. QTP doesn't have the ability to recognize when the ajax had finished. I've read that the web extensibility toolkit that is provided with QTP 9.5 and QTP 10 is the solution for my problem. However, I can't understand how this can help me: I need to know the ready state of the httpRequest object and continue the test when the state is 'complete'. But I don't know how to reach the httpRequest from the web extensibility toolkit. Any help would be appreciated.

解决方案

Thank you for your answers.

We did manage to solve our problem using the QTP Extensibilty toolkit: A4j uses a queue of listeners that are awaken before and after ajax (Depending on the type of the listener). In our solution, we implemented a Jscript function for each ajax component (e.g webButton):
1. Initialize a globalVariable to 0
2. registers a new function as a listener of type onafterajax:

_elem.ownerDocument.parentWindow.A4J.AJAX.AddListener({
    	onafterajax: function(req, event, data) {
    		globalVariable = 1;
    	}
    });

  1. Click the button
  2. Go into a sort of busy-waiting loop:

    while (globalVariable != 1) {	
    	_util.Wait(250);
    }
    

The function we registered is called when the ajax is finished and changes the globalVariable so the while loop will exit. I know this is ugly, but it works great.

Our only problem is that QTP 10 implements the _util.wait while QTP 9.5 doesn't. Without the wait, the browser will be stuck in an infinite loop and the registered function will never be called. Any solution regarding the implementation of a non busy-waiting wait in Jscript would be most appreciated.

这篇关于QTP网络extensibilty工具包和AJAX的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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