SimpleTest: How to make multiple Ajax posts and then save the data? I have a form with AJAX buttons that add items to a list. To SimpleTest the form, I need to make the AJAX post:

$this-&gt;drupalPostAJAX(NULL, $edit, array('op' =&gt; 'Add Item Button'));


...then POST the resulting $edit object with the Save button.

$this-&gt;drupalPost('admin/structure/fms_report/create', $edit, t('Save'));


My question is, how do I get the resulting $edit object after the first AJAX POST happens?
On subsequent tests of a form that has already been loaded and posted, this call will submit the form to the same URL with the field values resulting from any previous activity:

$this-&gt;drupalPost(NULL, NULL, t('Save'));


The $edit argument is only to submit new field values. And, passing NULL for $path uses the currently loaded page. So, to test my AJAX button that adds items to the form:

$this-&gt;drupalGet('path/to/my/form');
$this-&gt;drupalPostAJAX(NULL, NULL, array('op' =&gt; 'Add Item Button'));
$this-&gt;drupalPostAJAX(NULL, NULL, array('op' =&gt; 'Add Item Button'));
$this-&gt;drupalPost(NULL, NULL, t('Save'));


I was able to verify after this that two items had been added to the form as expected.