Tuesday, April 7, 2009

Quick & Dirty LoadRunner AJAX Debugging Tips

Since I've been battling with AJAX and LoadRunner, I thought I'd compose a quick note about what I've found.


LR 9.5 AJAX Click & Script Protocol

If playback of Click & Script is failing, try right-clicking on the C&S code that is breaking, and select "Use alternative navigation" option. It will comment-out the existing code and try HTML level code in its place.

This has been very helpful - in many cases it saves you from having to re-record the BP in HTML mode. I have had some cases where it just comments-out the GUI code and provides nothing in its place. I have also found, maybe a coincidence (not enough solid evidence that this is a 1:1 relationship), that URL mode functions work best when this happens.


Also, when Playback fails:
Action.c(194): web_button("INPUT_4") highest severity level was "warning", 55 body bytes, 252 header bytes [MsgId: MMSG-26388]
Action.c(204): web_browser("Sync") was successful [MsgId: MMSG-26392]
Action.c(211): web_browser("FireContinueButton1") was successful [MsgId: MMSG-26392]
Action.c(216): web_browser("Sync") was successful [MsgId: MMSG-26392]
Action.c(223): Downloading URL "https://app.url/OBG/Payment/PaymentInstruction.aspx" for an ActiveX object (asynchronous POST request) [MsgId: MMSG-26000]
Action.c(223): Warning -26276: JavaScript error (id=1) in line 5: ReferenceError: A is not defined [MsgId: MWAR-26276]
Action.c(223): Warning -26276: JavaScript error (id=0) in line 1: JavaScript evaluation error when executing function (by pointer) [MsgId: MWAR-26276]
Action.c(223): Warning -26000: ActiveX callback function failed. See previous message(s) [MsgId: MWAR-26000]
Action.c(223): web_button("INPUT_4") highest severity level was "warning", 55 body bytes, 252 header bytes [MsgId: MMSG-26388]
Action.c(238): Think time - Waiting 2.00 seconds (according to limit).


This seems to be a LR failure. In the example above, it is failing on pretty common Microsoft ASP .NET code. In this particular case it was a form that had validations going on,
and some state that was not being correctly handled during playback. At this time I have found no relief from HP for this issue and had to use URL mode recording snippets to get around the offending forms.


I have found a similar behavior in two places for the app I am working on. Curiously, if playback the script in LR9.1 it gets past one of them. Ugh! Seems to be a JavaScript handler issue in both cases, just maybe works a tiny bit better in 9.1.


Debugging JavaScript in IE:
I found these links to be useful...
http://www.jonathanboutelle.com/mt/archives/2006/01/howto_debug_jav.html
http://www.codestore.net/store.nsf/unid/DOMT-5UBUVW?OpenDocument

You need some components from MS Office for this to work, but this standard MS IE debugger is just okay. It doesn't seem possible to watch values (haven't figured it out anyway), but you can at least step through the JavaScript.

Try to figure out what is happening in the browser manually that is not happening when LoadRunner is playing the script back.

As mentioned above, LR playback failure may be related to a state or trigger that is not being setup or fired correctly. If you can identify this missing link, you can likely manipulate/call it from your script to work around the issue.

Calling a JavaScript trigger is easy if you can dig the code out of the browser:
web_browser("FireContinueButton1",
ACTION,
"EvalJavaScript=WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(\"ctl00$MasterPagePlaceholder$btnContinue\", \"\", true, \"\", \"\", false, true))",
LAST);


Just make sure that you follow all the standard embedded quote escape rules.

That's all I know at this time. Good luck.

No comments:

Post a Comment