Select an option in a dynamic select with codeception?

Michael J. Calkins picture Michael J. Calkins · Jul 1, 2013 · Viewed 10.4k times · Source
<select>
    <option value=''>-- Select an Option --</option>
    @foreach ($options as $option)
        <option value='{{ $option->value }}'>{{ $option->name }}</option>
    @endforeach
</select> 

Select the first dynamic option

Answer

Michael J. Calkins picture Michael J. Calkins · Jul 1, 2013
$option = $I->grabTextFrom('select option:nth-child(2)');
$I->selectOption("select", $option);
$I->click("Submit");