[Webtest] setSelectField: onclick code is executed several times

Philippe Schoch webtest@lists.canoo.com
Tue, 25 Apr 2006 10:45:22 +0200


This is a cryptographically signed message in MIME format.

--------------ms020506070008000207090902
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

I have a Select-Box (with two options) and some javascript attached:

<select id="Branch:OM_Branch" name="OM_Branch" 
onchange="document.forms['telcobillForm'].submit(); return false;">
<option value="1">Branch 1</option>
<option value="2" selected="selected">Branch 2</option>
</select>

Now the webtest step 'setSelectField' is executing the onchange script 
once, if I choose the first option. That's fine.
If I choose the second option, two times a request is sent (means 2x 
onchange is called) from the same original page (so the second request 
is sent from an old page as my application is treating the new response 
as the actual response, not allowing sending requests from the old page).
I traced webtest and was getting into htmlunit where the whole js story 
is executed and where the onchange event is handled. It's not obvious 
why the js code is executed twice. I even don't know if webtest or 
htmlunit is responsible for executing the js-code twice.

Had anybody met the same problem? It shouldn't be so unusual to have 
javascript on a Select-Box.

Here the Output:

[setSelectField] INFO (com.canoo.webtest.steps.Step) - >>>> Start Step: 
setSelectField "Select the second option" (4/5)
[setSelectField] DEBUG 
(com.canoo.webtest.steps.form.AbstractSetFieldStep) - Looking for 
element with id "telcobillForm:overview:menu:startMenu:OM_Branch"
[setSelectField] DEBUG 
(com.canoo.webtest.steps.form.AbstractSetFieldStep) - found element with 
id "telcobillForm:overview:menu:startMenu:OM_Branch": HtmlSelect[<select 
size="1" name="telcobillForm:overview:menu:startMenu:OM_Branch" 
onchange="document.forms['telcobillForm'].submit(); return false;" 
id="telcobillForm:overview:menu:startMenu:OM_Branch" class="dropdown_A_1">]
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Searching for the right option in HtmlSelect[<select size="1" 
name="telcobillForm:overview:menu:startMenu:OM_Branch" 
onchange="document.forms['telcobillForm'].submit(); return false;" 
id="telcobillForm:overview:menu:startMenu:OM_Branch" class="dropdown_A_1">]
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Searching option with text: Telenet Branch 2
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Examining option: HtmlOption[<option value="1" selected="selected">]
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Examining option: HtmlOption[<option value="2">]
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Found option by text: HtmlOption[<option value="2">]
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Content of 
window changed to http://localhost:8080/tb/telcobill.faces
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Content of 
current window changed, it will become current response
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Current form 
set to none
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Current 
response now: http://localhost:8080/tb/telcobill.faces
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Content of 
window changed to http://localhost:8080/tb/telcobill.faces
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Content of 
current window changed, it will become current response
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Current form 
set to none
[setSelectField] INFO (com.canoo.webtest.engine.Context) - Current 
response now: http://localhost:8080/tb/telcobill.faces
[setSelectField] DEBUG (com.canoo.webtest.steps.form.SetSelectField) - 
Selected option: HtmlOption[<option value="2" selected="selected">]

Greets and thanks for all the help,
Philippe

--------------ms020506070008000207090902
Content-Type: application/x-pkcs7-signature; name="smime.p7s"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7s"
Content-Description: S/MIME Cryptographic Signature

MIAGCSqGSIb3DQEHAqCAMIACAQExCzAJBgUrDgMCGgUAMIAGCSqGSIb3DQEHAQAAoIIJWTCC
AwcwggJwoAMCAQICEDGh5KvKbKlle3oHEKH/EI0wDQYJKoZIhvcNAQEEBQAwYjELMAkGA1UE
BhMCWkExJTAjBgNVBAoTHFRoYXd0ZSBDb25zdWx0aW5nIChQdHkpIEx0ZC4xLDAqBgNVBAMT
I1RoYXd0ZSBQZXJzb25hbCBGcmVlbWF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