Oct 14 2007 05:32:15 PM Posted By : Raghavan
Comments (0)

In this blog i am going to speak about functional testing Ajax based application using QEngine.

AJAX means Asynchronous Javascript And XML

First i will brief how normal application will be recorded and played back in QEngine,

On start recording and clicking on the elements in the web page will generate script for QEngine. The script will look like below

Code:
setWindow("title",)
clickButton....


Here the click button is the action you performed on the application.

What is setWindow ? Here i will explain it,

During playback, playback engine needs to identify the window to perform further action in the page. setWindow is used to identify the browser window in which the target element is present.

setWindow will be recorded in the script in the following scenario,
    i) whenever the page is refreshed or loaded freshly
    ii) whenever the action is performed in the alternative window during recording
    iii) whenever a new window is launched and some action is performed there.
    iv) whenever the page title changes during any action perfromed in the application

During playback of the script , QEngine can identify the window over which the desired action to be fired.

Also during playback, setWindow call will wait for the page to load completely before proceeding to perform further script actions.

Now come to AJAX application. In AJAX following scenario will be difficult to handle using normal setWindow call.

Scenario 1:

AJAX will asynchronously send the request and dynamically add element's to the page without refreshing / loading the page.

Possible Problem

As the elements are getting loaded dynamically, there may be a chance of setWindow may not get recorded. Hence during playback, if there is any network delay the element's might loaded with delay.
But QEngine will look for the elements immediately which may not be there. Due to which the script may fail.

Solution

QEngine has in-built function which will take care of handling such scenario.

In QEngine there is a separate category for "AJAX Functions". The AJAX functions contains the following functions,

waitForElement & waitForDynamicElement- This will wait for the recorded element to appear in the page. Once it idenifies the element in the page it will proceed to fire the needed actions.
waitForText - This will wait until configured text appear in the page. After the text is displayed in the page, this will proceed for further actions in the script.
waitForTitle - This will wait until window with configured title is found.
waitForElementRemoval & waitForDynamicElementRemoval - This will wait for the recorded element to be removed from the page.

The timeout for wait can be configured for the above functions, to stop waiting and proceed for further actions.

Before proceeding with the further script action's in the above specified scenario you can insert following script line to wait for the element to show up in the page,
Code:
waitForElement("",20)


The above statement will make QEngine to wait for the element to show up in the page for maximum timeout of 20 sec. If it is doesn't show up then it will proceed to further script actions.

Scenario 2:

There will not be page navigation in the application. Instead the complete page will be shown on AJAX request. Ex: Typical Backbase based web application.

Possible Problem:

Here the setWindow will be recorded only once. But the page might change on various page submit.

Solution

Here also you have to use appropriate AJAX function listed above to handle page changes.

Where to insert the AJAX function in the script,

Next to the action which caused the page to change, you should insert the AJAX functions, which will make QEngine to wait until specified element to show up.

Summary: QEngine has the powerful set of functions which can be used to automate AJAX rich applications.

I will catch you with different tips to effectively use QEngine for the automation in my next blog.

Cheers,
Raghavan

No one has commented yet! Be the first one to comment!

Post Comment

38.107.179.229 (38.107.179.229)