Trying to set a checkbox in a form , triggering an onclick!

1,867 views
Skip to first unread message

bruce

unread,
Aug 1, 2012, 10:35:18 PM8/1/12
to casp...@googlegroups.com
Hi.

I've got a test app that has a series of checkboxes that are in a
form. The test has to select one/multiple checkboxes, and then submit
the form. Successfl submittal of the form, generates the next page.

Each checkbox triggers an onclick event.

I've crafteed my tesst to run, setting a couple of the checkboxes,
using the ID/Name of the checkboxes from the HTML. Without setting the
checkbox, the test runs, the app generates the correct next page.

However, I'm apparently screwing something up, as I can't seem to get
the checkboxes to set via the "fill" method.

My test code is:

<div id="win0divCLASS_SRCH_WRK2_MON"><input type="hidden"
name="CLASS_SRCH_WRK2_MON$chk" id="CLASS_SRCH_WRK2_MON$chk" value="">
<input type="checkbox" name="CLASS_SRCH_WRK2_MON"
id="CLASS_SRCH_WRK2_MON" tabindex="46" value="Y"
onclick="setupTimeout2(); this.form.CLASS_SRCH_WRK2_MON$chk.value=(this.checked?'Y':'N');doFocus_win0(this,false,true);">
</div></td>

this.fill('form[name="win0"]', {
'OSR_CAT_SRCH_WK_DESCR': deptSelVal,
'CLASS_SRCH_WRK2_ACAD_CAREER': careerMenuSelVal,
'CLASS_SRCH_WRK2_CAMPUS': campusMenuSelVal,
'CLASS_SRCH_WRK2_INCLUDE_CLASS_DAYS': dayWeekMenuSelVal,
'CLASS_SRCH_WRK2_SSR_OPEN_ONLY': false,

'CLASS_SRCH_WRK2_MON': true, <<<<<<<<<<<<<<<<<<<< Trying to
set this checkbox!!!
'CLASS_SRCH_WRK2_TUES': false,
'CLASS_SRCH_WRK2_WED': false,
'CLASS_SRCH_WRK2_THURS': false,
'CLASS_SRCH_WRK2_FRI': false,
'CLASS_SRCH_WRK2_SAT': false,
'CLASS_SRCH_WRK2_SUN': false

}, true);
if(debug==1)
{
console.log(' right here......');
console.log(' sb = '+searchBTNID);
}

//this.click('#CLASS_SRCH_WRK2_SSR_PB_CLASS_SRCH');
this.click(searchBTNID);

I've also tried to set the checkbox manually, using a "click" event
prior to filling the form to see if that made a diff...

As far as I can tell, the API indicates that this "should" work.

Thanks for any pointers on this

Nicolas Perriault

unread,
Aug 2, 2012, 2:53:26 AM8/2/12
to casp...@googlegroups.com
On Thu, Aug 2, 2012 at 4:35 AM, bruce <bado...@gmail.com> wrote:

> Each checkbox triggers an onclick event.

The fill() method won't perform a "click" on elements; it will just
set their values.

If you want to perform clicks on your checkboxes, you'll have to do it
programmatically.

++

--
Nicolas Perriault
https://nicolas.perriault.net/http://www.akei.com/
Skype: nperriault
Phone: +33 (0) 660 92 08 67

Nicolas

unread,
Aug 13, 2012, 5:02:28 AM8/13/12
to casp...@googlegroups.com
Hi,

Any hints on how to do it programmatically ?

Thanks,

Nicolas

Nicolas Perriault

unread,
Aug 13, 2012, 6:00:56 AM8/13/12
to casp...@googlegroups.com
On Mon, Aug 13, 2012 at 11:02 AM, Nicolas <n...@mechin.org> wrote:

> Any hints on how to do it programmatically ?

Basically casper.click('input[type="checkbox"][name="checkbox-name-attr-value"]')

http://casperjs.org/api.html#casper.click

viktor....@gmail.com

unread,
Feb 2, 2015, 6:19:57 AM2/2/15
to casp...@googlegroups.com


On Thursday, August 2, 2012 at 8:53:26 AM UTC+2, Nicolas Perriault wrote:
On Thu, Aug 2, 2012 at 4:35 AM, bruce <bado...@gmail.com> wrote:

The fill() method won't perform a "click" on elements; it will just
set their values.


So how can I set checkbox value to checked ?
Should I pass "checked" as a string or set it to true ?
Reply all
Reply to author
Forward
0 new messages