2 messages in com.canoo.lists.webtest[Webtest] onclick event handler on ch...
FromSent OnAttachments
vikr...@mastek.com05 May 2005 02:10 
Marc Guillemot05 May 2005 02:30 
Subject:[Webtest] onclick event handler on checkbox.
From:vikr...@mastek.com (vikr@mastek.com)
Date:05/05/2005 02:10:21 AM
List:com.canoo.lists.webtest

Hi,

When we set the value of the checkbox the onclick event handler is not invoked.

We have a web page on which there is checkbox present the code for the checkbox is somewhat like this.

<input type="checkbox" name="isEmpAdsEqual" value="on" onclick="javascript:fnSameAsLegalAdd()">

And the webtest script is

<setcheckbox name=" isEmpAdsEqual" value="on" />

When we run the webtest script the onclick event handler on this checkbox is not getting called. As a result of which the further verifications fail, as there are some hidden fields that are set in the JavaScript function.

The HTMLUnit source for the HtmlCheckBoxInput element mentioned "Both IE and Mozilla will first update the internal state of checkbox and then handle "onclick" event". Due to this comment, following code changes were done to com.canoo.webtest.steps.form.SetCheckbox class in the doExceute method.

Previous Code...

boolean checked = isChecked();

checkBox.setChecked(checked);

New code....

boolean checked = isChecked();

// If original value is same as what is being set then do nothing.

// Otherwise call the click method which will toggle the check box state

// and also call onclick event handler.

if(checkBox.isAttributeDefined("checked") != checked)

{

checkBox.click();

//checkBox.setChecked(checked);

}

With the new code the onclick event gets called and everything works smoothly. Mind you if we have the onchange event handler on the checkbox, it still does not get called though!!!

I am not sure whether the fix that I have done is the right place to do this fix for this issue. If anyone can throw some light on this it will be great :-).

Thanks & Regards Vikram Shitole Mastek Ltd Phone No : 56072000/ 56072100 extn 2131 Mastek on the web: <http://www.mastek.com/> www.mastek.com

"No one knows what he can do till he tries."

MASTEK "Making a valuable difference" Mastek in NASSCOM's 'India Top 20' Software Service Exporters List. In the US, we're called MAJESCO