Hi,
I try to write a test where I post a multiple selectbox and want to verify both options are selected. This never succeeds.
drupalPost does submit both option values and if I use the modules API I can see that both variables are set correctly.
If I look at the code inside assertFieldByXPath the method will use this part line 2307 drupal_web_test_case.php:
elseif (isset($field->option)) {
// Select element found.
if ($this->getSelectedItem($field) == $value) {
$found = TRUE;
}
else {
// No item selected so use first item.
$items = $this->getAllOptions($field);
if (!empty($items) && $items[0]['value'] == $value) {
$found = TRUE;
}
}
}
getSelectedItem will loop through the elements children and return the _first_ that is found "selected".
If I didn't overlooked something this forbids that more than one value can be valid.
Wouldn't it be better if getSelectedItem was getSelectedItem(s) and return an array?
Maybe it would be better to pass the value into the loop?
Or maybe there is a xPath expression that can directly check if the demanded item is selected?
Comments
Comment #1
boombatower commentedComment #2
jhedstromThis can be done with xpath now.