[Webtest] Member Poll: javascript solution for WebTest
McCorkindale, Catherine
webtest@lists.canoo.com
Tue, 20 Aug 2002 15:57:29 -0400
Today we found a situation similar to Erik's Case 1 for using webtest with a
page containing javascript. In a few forms we set the value of a hidden
input field using the onClick() method from some submit buttons. A simple
example of our JSP code using the onClick() method to set a hidden field
looks like:
<input type="submit"
onClick="document.config_form.configSubmit.value='submit'" value="<%=
bundle.getString("button.submit") %>">
<input type="submit"
onClick="document.config_form.configSubmit.value='restore'" value="<%=
bundle.getString("button.restore") %>">
<input type="hidden" name="configSubmit">
We recently started using Webtest and have often found a suitable
work-around for testing or modifying some of the pages that use javascript.
In the example above, we haven't found another solution that works as well
for us. I'll look for more javascript examples as we continue trying to use
webtest.
Catherine
-----Original Message-----
From: Erik.Ostermueller@alltel.com [mailto:Erik.Ostermueller@alltel.com]
Sent: Tuesday, August 20, 2002 12:18 PM
To: webtest@gate.canoo.com
Subject: RE: [Webtest] Member Poll: javascript solution for WebTest
In the short term, I need to add some very limited, temporary support
the javascript patterns in the forwarded email.
I want to run my design ideas against you all.
I'm not that familiar with the code, so I'm hoping
you can tell me precisely how crazy my ideas are.
Chime in if this kind of support will benefit the community
and I'll post my changes. I've seen patterns like this
with three different JSP frameworks. Have you all seen it elsewhere?
-------------------- Case 1 -----------------------
Java script that sets hidden fields prior to submit
---------------------------------------------------
For javascript that resides in the <FORM> tag (as shown below)
I'll have to modify the ClickButton task.
If the ClickButton is the submit button, then I'll have to
a) Retrieve the javascript from the Form element.
b) If I find our standard js hidden field 'setter' function
(jsSetFormParameters)
c) then I'll set hidden fields by dynamically creating and
dynamically adding one 'setinputfield' task for each of our
special hidden fields.
-------------------- Case 2 ---------------------------------
'Selecting' a row in a table / submit form based on selection
-------------------------------------------------------------
a) I'll add a new task -- perhaps something like 'RowSelection'
b) It will contain a required, nested 'index locator'. I considered
a table locator instead, but the table locator's column attribute is
required.
When selecting a row, we don't care about the column.
c) Retrieve the java script from the <tr> element, onDblClick attribute
(as shown below).
d) proceed with step b) for Case 1.
> -----Original Message-----
> From: Ostermueller, Erik
> Sent: Thursday, August 15, 2002 5:16 PM
> To: webtest@lists.canoo.com
> Subject: RE: [Webtest] Member Poll: javascript solution
> for WebTest
>
>
> I apologize for not getting back to you sooner on this issue;
> This is really something we could use!! :- )
>
>
> Here are a few things we need out of JavaScript:
> 1) Form submission.
> We use hidden fields to help maintain state.
> When you want to submit a form, you call a our own jsExecute()
> It will set certain hidden fields before the POST.
>
> Here are some exerpts from our html files:
> a)
> <FORM
> ACTION="test.crm;jsessionid=C584934B397086FAEB5E35A7FE522490"
> METHOD="post"
> ONSUBMIT="JavaScript:jsSetFormParameters(0, 'finish');"
> ONRESET="JavaScript:jsExecute(0, 'cancel');">
>
> b) This code is used to select a row in a table
> and pass the index of the
> selected row to the
> server.
>
>
> <tr onMouseDown="jsHandleTableMouseDown();"
> id="CustomerRow"
> onClick="jsSelectCustomer(0);"
> onDblClick="JavaScript:jsExecute(0,
> 'select?id=0');"
> border="1"
> class="gridEvenRow"
>
> >
> 2) Field validation -- check for the
> user's input and validate it BEFORE they
> click the submit button.
>
> Don't have have any specific examples. Stay tuned.
>
>
> #############################################################
> J a v a S c r i p t
> #############################################################
> function jsSetFormParameters( thisComponentId,
> thisActivationKey)
> {
> with ( document.forms[0] )
> {
> toComponentId.value = thisComponentId;
> activationKey.value = thisActivationKey;
> scrollLeft.value = document.body.scrollLeft;
> scrollTop.value = document.body.scrollTop;
>
> if ( window != null )
> {
> if ( window.event != null )
> {
> controlFocus.value = window.event.srcElement.name;
> }
> else
> {
> controlFocus.value = "";
> }
> }
>
> }
>
> }
>
> function jsExecute( thisComponentId, thisActivationKey )
> {
> with ( document.forms[0] )
> {
> jsSetFormParameters(thisComponentId,
> thisActivationKey);
> submit();
> }
>
> }
>
>
>
>
>
>
> > -----Original Message-----
> > From: Ostermueller, Erik
> > Sent: Monday, July 15, 2002 2:42 PM
> > To: webtest@lists.canoo.com
> > Subject: RE: [Webtest] Member Poll: javascript solution
> > for WebTest
> >
> >
> > This page
http://htmlunit.sourceforge.net/generaldoc11.html
> documents some JavaScript support for a web testing framework
> called HtmlUnit (not to be confused with 'HttpUnit').
>
> -----Original Message-----
> From: Ostermueller, Erik
> Sent: Monday, July 15, 2002 2:08 PM
> To: webtest@lists.canoo.com
> Subject: RE: [Webtest] Member Poll: javascript solution
> for WebTest
>
>
> I'm working on getting some stories together.
> It may take me a few days to get ahold of the right people.
> Thanks for asking!
>
> -----Original Message-----
> From: Dierk König [mailto:Dierk.Koenig@canoo.com]
> Sent: Friday, July 12, 2002 3:41 AM
> To: webtest@lists.canoo.com
> Subject: [Webtest] Member Poll: javascript solution for WebTest
>
>
> Hiall,
>
> for the next activities concerning JavaScript support
> for WebTest
> I would like you to send your JS "stories" to this list.
>
> What JS do you use in your webapp that you would like to test
> with WebTest?
>
> We would appreciate if you could send your JS code under test
> with your story.
>
> The more you send, the better we can serve you.
>
> Thanx in advance for your contribution.
> Mittie
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest
_______________________________________________
WebTest mailing list
WebTest@lists.canoo.com
http://lists.canoo.com/mailman/listinfo/webtest