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
2009-01-28 14:28:39
That is the exact answer I have
TStamper
2009-01-29 14:45:11
A:
Yes, take a look at SeleniumIDE. Very good for automated acceptance testing.
Hates_
2009-01-28 14:30:06
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
2009-01-28 14:38:04