How do I programatically submit a webform via drupal_form_submit? Drupal 7, Webform 3

I want to programmatically submit a webform via drupal_form_submit. However, I'm having difficulty finding a $form_state structure that works. I've submitted my webform via the ui and examined the $form_state variable in my validate callback function, but I still can't get it to work.

My webform has one textfield named "first_name". Below is a snippet of code I've used to test. Whenever I run it, $form_errors is null. With no errors, I would expect the code to have worked.  However, when I check the webform results, it says there are no submissions.

&lt;?php
$form_id = 'webform_client_form_55805';
$form_state = array(
  'values' =&gt; array(
    'submitted' =&gt; array(
      'first_name' =&gt; 'David',
    ),
  ),
);
$node = node_load(55805);
$submission = (object) array();

drupal_form_submit($form_id, $form_state, $node, $submission);
$form_errors = form_get_errors();
?&gt;


Am I doing it wrong?  Is there a better way?  Should I be using webform_client_form_submit instead?

I looked at this Q&amp;A, but it doesn't work for me and seems a bit convoluted: How to submit webform programmatically with Ajax?
I used PhpStorm and xdebug to step through the form.inc code and finally found the correct structure for my $form_state.  The structure I posted was close, just needed to add the 'op' =&gt; t('Submit').  See my final working code below.

To answer my questions:


Yes, drupal_form_submit is what I should be using.
See code below for the magical $form_state structure.


&lt;?php
$form_id = 'webform_client_form_55805';
$form_state = array(
  'values' =&gt; array(
    'submitted' =&gt; array(
      'first_name' =&gt; 'David',
    ),
    'op' =&gt; t('Submit'),
  ),
);
$node = node_load(55805);
$submission = (object) array();

drupal_form_submit($form_id, $form_state, $node, $submission);
$form_errors = form_get_errors();
?&gt;