I am using Cocoon to add records. IDs look like workshop_instance_sessions_attributes_1477654140_start_time
. At the moment I am traversing the DOM and grabbing the dynamically generated IDs (this works fine) so I can use them to reference the input to fill in. I have tried many things (many that work in console) and still cannot seem to get the spec to work. Below are a selection of things I've tried (first
is the variable which holds the id and @time
is basically Time.now that increments as a block executes).
Works in console:
page.evaluate_script("document.getElementById('#{first}').value = '#{@time.strftime('%Y-%m-%eT%H:%M')}'")
page.evaluate_script("$('##{first}').val('#{@time.strftime("%Y-%m-%eT%H:%M")}')")
Doesn't work in console:
fill_in first, with: @time.strftime("%Y-%m-%eT%H:%M")
find("##{first}").set(@time.strftime("%Y-%m-%eT%H:%M"))
These are all already within a within block (a common issue I run into) that I know is working correct as the first variable is being correctly set.
As reference my html looks like this:
<input class="form-control" type="datetime-local" name="workshop_instance[sessions_attributes][1477655024][start_time]" id="workshop_instance_sessions_attributes_1477655024_start_time">
Any pointers on how to get this spec to work would be much appreciated.