如何检查'select'是否有一些选项?



I am writing test script using Selenium & PHPUnit.
I have got a form containing drop-down lists. I have to verify if data is read from database and presented as options in the 'select' elements.

When there is no options in the select, the code is:

<select id="list">

</select>


Method assertNotEmpty("list") doesn't work.

Any ideas?

`if (document.getElementById('list').innerHTML !== "")

//do something` - might not work in explorer.

You can get an array of options using selectOptionValues() function.

$optionValues = $this->select($this->byName('name_of_dropdown'))->selectOptionValues();
$this->assertGreaterThan(0, count($optionValues));

Hope this will help to resolve your issue.