如何在没有任何选项的情况下测试 select 框 selected with codeception?

How to test select box without any option selected with codeception?

所以该字段的值应该是第一个选择的选项。

我看到问题就在这里

public function seeOptionIsSelected($select, $optionText)
{
    $selected = $this->matchSelectedOption($select);
    $this->assertDomContains($selected, 'selected option');
    //If element is radio then we need to check value
    $value = $selected->getNode(0)->tagName == 'option' ? $selected->text() : $selected->getNode(0)->getAttribute('value');
    $this->assertEquals($optionText, $value);
}

这种情况可以通过以下方式进行测试:

$I->seeElement("#id_of_the_select_box");
$I->dontSeeElement("#id_of_the_select_box option[selected='selected']");