You need to locate the hidden field and set its value. There are a couple ways, this is probably the simplest
find(:xpath, "//input[@id='my_hidden_field_id']").set "my value"
If you’re executing a client_side script in production, you could just tell capybara to run it with a javascript-compliant driver
page.execute_script("$('hidden_field_id').my_function()")