[Webtest] __doPostBack function for ASP forms

Florent Blondeau Florent Blondeau <fblondeau@pingwy.com>
Wed, 05 Dec 2007 10:52:11 +0100


Hi everybody,

I have a huge problem that I would like to share with you, for the case 
you'd know how to solve it.
Actually, it's only a "huge" problem because it's the last point of my 
first test plan, and it fails on the very last step....
In fact, it is an ASP.NET generated javascript stub that makes me become 
mad !!!
Well I think it comes from this point. That is my story :

Once upon a time in the web, there was a web site that proposed a caddie 
scenario to his customers. A robot was sent to test it.
This robot did a good job while testing the 9 steps of the scenario. All 
was right, when the last "Submit" button came on the scene...
The fight seemed to be easy for the robot, but as the wind strength 
became to grow, the webusers began to leave the site. e-Tumbleweeds 
were flewing  on the forms, and  the air became  full of fear !!! The 
robot have missed his first attacks...

Hum... Well... It was just to make you smile

So I test 9 steps of a scenario without any problem. Then I arrive to 
the last submit button. All my fields are well-filled. What happens is 
when I do a clickButton() step, this leads me to a page that I don't 
expect that tells me the navigation is wrong

In the javascript code there is a __doPostBack() method that submit the 
form. This method may be trigger by the click (i don't really see why, 
but I'm not a Javascript Guru) and, in my mind, is used to  submit the form.

<script language="javascript" type="text/javascript">
<!--
    function __doPostBack(eventTarget, eventArgument) {
        var theform;
        if (window.navigator.appName.toLowerCase().indexOf("microsoft") 
 > -1) {
            theform = document._form;
        }
        else {
            theform = document.forms["_form"];
        }
        theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
        theform.__EVENTARGUMENT.value = eventArgument;
        theform.submit();
    }
// -->
</script>

Is there a way in Webtest to only trigger the Javascript of abutton 
without sumitting the form (I think the navigation error come from the 
fact the POST method is not Ajax called ) ?

Thanks for reading me

Florent

PS: the __doPostback method is present on the other steps of the 
scenario, and submitting the forms on the pages works well

-- 

Pingwy
27, rue des arčnes
49100 Angers