|
eValid -- Automated Web Quality Solution
Browser-Based, Client-Side, Functional Testing & Validation,
Load & Performance Tuning, Page Timing, Website Analysis,
and Rich Internet Application Monitoring.
|
|
eValid -- Testing AJAX Applications -- Script Development Methodology
eValid Home
Key Ideas
|
- AJAX applications, asynchronous by nature, are difficult to test.
- A good AJAX test plays back fully synchronized without relying on Waits.
- Several methodologies support creating such tests.
- Experimentation is usually required.
|
Background
AJAX applications, by their nature, behave asynchronously with respect
to the user.
The underlying "AJAX engine" processes actions ahead of, in parallel
with, and even long after a user makes a request.
The usual methods test recording
of associating a user action with a specific future action to take
-- in effect writing down a future instruction for the playback
engine to follow -- no longer apply.
What you see and what you do no longer DIRECTLY affects what
you see next.
That's the benefit of AJAX's asynchronous nature.
An AJAX application can do things that would otherwise frustrate
the user, thereby significantly enhancing
the quality of the user's experience using the application.
Reality Check
The fact is, in testing an AJAX application, the issues
is usually not whether a recording from life would work reliably,
but whether any script can be manipulated to reliably play back at all!
Arriving at a Wait-time independent,
reliable (synchronized) playback script is the real goal.
A Baseball Metaphor:
How do you explain to someone how to hit a baseball?
It's a simple enough notion:
you stand at the plate, watch the ball as it's pitched,
swing the bat at the right time,
hit the ball right on the bat's sweet spot,
and watch the ball fly over the center field fence!
Home Run!
If it were that easy to do we'd all be Babe Ruth
(sorry, Barry Bonds).
But don't try to tell a slugger that it's impossible:
they just do it!
Ask a slugger how he does it and he'll say,
"I just do it, but I don't know how to explain it.
You've got to learn to do it by yourself."
Methodology Options
It's very difficult to define a precise methodology that applies
the test script development for AJAX applications, but what
appears below are some options that you can apply,
accompanied with very general outline of "how to do it."
- Exploit A Priori Synchronization Features
In some cases you may know in advance, or you can deduce
synchronization pivots for the application under test.
Success is more assured if you have superior knowledge about the
application.
This is the case with
Morfik where
we know (for at least some pure-Morfik pages) what the
internal
Morfik Synchronization Method is in advance.
Other AJAX development frameworks also make this information
available, but some keep in very private (proprietary) and
you need to discover it on your own, by experimentation.
- Systematically Include Synchronization Steps
When you know in advance that you're trying to record an
AJAX application,
you might choose an approach that systematically INCLUDES
synchronization steps after every significant action,
and certainly after every action that you suspect will
activate AJAX-based asynchronous behavior.
Even when they are not necessary to assure complete playback
synchronization they can do no harm.
eValid provides a range of methods
to choose from, as shown in the
Synchronization Mode Summary.
For most AJAX applications
the synchronize on text string command, SyncOnText,
is the one most likely to succeed.
This has the advantage of being Class B
(can be done from the GUI),
and does not involve editing the script manually.
Important note to remember, if this is not already obvious:
no two AJAX applications are quite alike and "...your mileage will vary."
- Successive Refinement
This approach -- very much akin to the "scientific method" which
emphasizes experimentation --
is the method that ultimately will yield the goal, a
script that replicates the human activity AND plays back with
all of the Wait times zeroed out.
- Record a Candidate Script "From Life"
Make a recording with Real Time recording enabled that visits
the pages that you want to visit.
Your own "human recording time" ("from life")
synchronization logic will help create
a script that probably will play back fully synchronized
(with Wait times included) the first time.
As the human user you don't necessarily know what's next,
so you wait until things settle down; then you take the next action.
- Every Action Must Produce Recording Activity
Make sure every action you take on the screen produces something in the script window,
showing that eValid is recording actions successfully.
If you take an action and eValid doesn't record ANYTHING,
then you'll need to turn something ON that is currently OFF.
This might even include the use of Application Mode actions.
- Wait Times Unreliable For Playback
Scripts with Wait times are intrinsically unreliable.
Even if you multiply Wait times by 2.0 or 10.0 there are
some AJAX applications which take "too long" and thus for
which the automated script playback will fail.
We need to make the script insensitive to Wait time induced behavior
but adding steps that assure synchronization.
- Vary The Wait Time Multiplier
You can control playback Wait times with the
Wait Time Multiplier,
a settable constant that multiplies all Wait times at playback.
- Study How Wait Time Affects Playback Synchronization
After choosing a new Wait Time Multiplier
watch the Script Window, the Browser Window,
and Event Log as the script plays to get a sense
of where the script "plays ahead" of the test.
These points in the script are the ones which require additional
synchronizations.
Hint:
Starting with a multiplier of
0.0 may be too severe a first step.
Try starting with 0.2, then 0.1, then
0.01, then 0.0.
- Add A Synchronization Step and Retry
Single step (F7) through the playback one recorded command
at a time to the point in the script
where you want to add a synchronization step.
You can either use evalid's Insert Script feature
or hand-edit the script in the Script Window.
Once edited, retry the playback and identify if the synchronization
was successful.
- Retry After Modification
Repeat the above step after you successfully synchronize
the first de-sync.
Continue until you have no more de-sync's that you need to add,
and the script plays back without loss of synchronization.
- Confirm Final Script
In a brand new instance of eValid
(to eliminate any possible memory effects),
run the script with
a Wait Time multiplier of 0.0.
If you get a Green Screen you're done!
- Ad Hoc Methodology
It's perfectly OK to draw parts of your actual methodology
from some of the above suggestions.
Or, you can create your own methodology,
tailored to the specifics
of how the particular AJAX application you're trying to test
actually works.
Here is a list of things that we've found useful
in ferreting out how to create the correct synchronizing
command or action:
- Use the PageMap at the object, up and down a few elements, to see
how it might be organized.
- Study how a "nearby element" is doing the same thing or the
same kind of thing.
- The visible text in an ALT tag above the element may
give you a clue as to how it is being treated.
- Experiment with the IndexFind command to see where a particular
event or action is happening on the page.
- View the source and see if you can make a deduction from
the material there.
Resources
Here are resources that will assist in creating reliable
functional and loading tests for AJAX applications.