Search code examples
codeception

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


So the value of the field should be the first option selected.

As i see the problem is here

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);
}

Solution

  • This situation can be tested with the following:

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