New to js, casperjs, jquery. I'm having trouble with input selector in JQuery + Casperjs. I'm trying to input text when I only have the NAME. It doesn't have an ID and the CLASS is the same as other inputs so when I use CLASS, it inputs my text into all 4 boxes that have the same CLASS.
I'm trying to input the Begin Date and End Date under "Instituton date". but also leave the Begin Date and End Date under "Filing dale" empty.
I was able to fill the NON-date inputs because they have IDs.
(i've simplified the class name and ID since the website I'm using has long names)
For ID I can use a hashtag # before the ID (this works):
this.evaluate(function(search){
return jQuery('input#IDname').attr({'value': search});
}, 'MYinput');
For CLASS I can use a period . before the CLASS (this works):
this.evaluate(function(search){
return jQuery('input.CLASSname').attr({'value': search});
}, 'MYinput');
But I'm unable to figure out how to use the NAME of an input. I've tried the following and many more (none of them worked): I feel that I am missing something very simple.
Didn't work:
this.evaluate(function(search){
return jQuery('input[name="NAMEofinput"]').attr({'value': search});
}, 'MYinput');
Didn't work:
this.evaluate(function(search){
return jQuery(x('//input[@name='NAMEofinput']")).attr({'value': search});
}, 'MYinput');
Didn't work:
casper.then(function() {
this.sendKeys(x('//input[@name='NAMEofinput']', 'MYinput'));
});