Search code examples
codeception

Select an option in a dynamic select with codeception?


<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


Solution

  • $option = $I->grabTextFrom('select option:nth-child(2)');
    $I->selectOption("select", $option);
    $I->click("Submit");