Simpletest on select field loaded by ajax
You should set the $path parameter to NULL when submitting to the same form. Otherwise drupalPost / drupalPostAJAX will first retrieve the page again, and thus generating a new form instead of rebuilding the current one.

The following test should do what you want:

// First retrieve the page once
$this-&gt;drupalGet('mymodule/mypath');

// Set $path to NULL on subsequent requests to the same form
$edit = array('system[foo]' =&gt; 1);
$this-&gt;drupalPostAJAX(NULL, $edit, 'system[foo]');

$edit = array('system[bar]' =&gt; 2);
$this-&gt;drupalPost(NULL, $edit, t('Submit'));


The test case succeeds when performed on the following form:

function mymodule_myform($form, &amp;$form_state) {
  $foo_options = array('A', 'B', 'C');
  $foo_default = isset($form_state['values']['system']['foo']) ? $form_state['values']['system']['foo'] : NULL;

  $form['system']['#tree'] = TRUE;

  $form['system']['foo'] = array(
    '#type' =&gt; 'select',
    '#options' =&gt; $foo_options,
    '#default_value' =&gt; $foo_default,
    '#ajax' =&gt; array(
      'callback' =&gt; 'mymodule_myform_ajax_callback',
      'wrapper' =&gt; 'bar-div',
      'method' =&gt; 'replace',
    ),
  );

  $bar_choices = array(
    0 =&gt; array('aaa', 'bbb', 'ccc'),
    1 =&gt; array('ddd', 'eee', 'fff'),
    2 =&gt; array('ggg', 'hhh', 'iii'),
  );
  $form['system']['bar'] = array(
    '#prefix' =&gt; '&lt;div id="bar-div"&gt;',
    '#suffix' =&gt; '&lt;/div&gt;',
    '#type' =&gt; 'select',
    '#options' =&gt; isset($bar_choices[$foo_default]) ? $bar_choices[$foo_default] : array(),
  );

  $form['submit'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Submit'),
  );
  return $form;
}

function mymodule_myform_ajax_callback($form, $form_state) {
  return $form['system']['bar'];
}