29/06/2014 - BEHAT
Eğer selectbox seçeneklerini behat ile kontrol etmek isterseniz, aşağıdaki örneği kullanabilirsiniz.
<select id="my-select-box">
<option value=""></option>
<option value="1">11</option>
<option value="2">22</option>
<option value="3">33</option>
</select>
Feature: Dummy feature
Scenario: Selectbox will contain specific set of data
Given I am "/home"
And the selectbox "my-select-box" should have a list containing:
"""
11
22
33
"""
class FeatureContext extends MinkContext implements KernelAwareContext
{
...
...
/**
* @Then /^the selectbox "([^"]*)" should have a list containing:$/
*/
public function shouldHaveAListContaining($element, PyStringNode $list)
{
$session = $this->getSession();
$page = $session->getPage();
$element = $page->findById($element);
if (is_null($element)) {
throw new \InvalidArgumentException(sprintf('Could not evaluate CSS for "%s".', $element));
}
if ($element->getText() != implode('', $list->getStrings())) {
throw new \Exception(sprintf('Element "%s" content mismatch.', $element));
}
}
...
...
}