I have this drop down list:
<select name="date" class="form-control" on-change:Calendar.submitFilterForm();">
<option value="2015-09-15">Tue 2015-09-15</option>
<option value="2015-09-16">Wed 2015-09-16</option>
<option value="2015-09-17">Thu 2015-09-17</option>
<option value="2015-09-18">Fri 2015-09-18</option>
<option value="2015-09-19">Sat 2015-09-19</option>
<option value="2015-09-20">Sun 2015-09-20</option>
<option value="2015-09-21">Mon 2015-09-21</option>
<option value="2015-09-22">Tue 2015-09-22</option>
</select>
Each night at 00:00 AM (or a few seconds later) the drop-down list above is updated with a new (next) day, for example <option value="2015-09-23">Wed 2015-09-23</option>
would be added and <option value="2015-09-15">Tue 2015-09-15</option>
would disappear.
I then want to click on that drop-down list option that is added as soon as it is visible. Is it possible?
Now I use:
casper.thenEvaluate(function(){
var form = document.querySelector('.form-control');
form.selectedIndex = 7; //7 equals the last value currently visible.
$(form).change();
});
It works but how should I do to make casperjs wait until the options is visible and then directly click on it
?
Maybe I can make a variable var ClickValue = "2015-09-23"
or something like that?