tags:

views:

134

answers:

3

I have started testing my UI using qUnit, so I need to simulate some user interaction. Is it possible to "simulate" a user clicking a checkbox using javascript ?

A: 

You can look at this:

Simulate a buttonclick via javascript

It is the other way arround, so i'm not sure if it works on checkboxes too.

Ikke
That is the exact answer I have
TStamper
A: 

Yes, take a look at SeleniumIDE. Very good for automated acceptance testing.

Hates_
A: 

Thx guyes. I figured it out about two seconds after I posted the question. It was as you say simpler than I had imagined

document.getElementById('cb1').click();

did the trick

Edit: It seems in IE7 (and perhaps other browsers) the the click method will not actually check the checkbox. So to fully simulate you need to "check" the checkbox before clicking it

document.getElementById('cb1').checked=true
document.getElementById('cb1').click();
BjartN