giorgiosironi / phpunit-selenium

Selenium RC integration for PHPUnit
http://www.phpunit.de/
Other
601 stars 271 forks source link

assertSelectOptions errors on empty options #357

Open mc-murphy83 opened 8 years ago

mc-murphy83 commented 8 years ago

assertSelectOptions gives an error when trying to check for Option-Fields with neither value nor innerHTML set. example:

<select id="payment_method">
<option value=""></option>
<option value="mastercard">MasterCard</option>
<option value="visa">VISA</option>
</select>

When using the following Selenese (which works fine in the SeleniumIDE)

 <tr>
 <td>assertSelectOptions</td>
 <td>id=payment_method</td>
 <td>,mastercard,visa</td>
 </tr>

Results in the following error:

Argument #2 (No Value) of PHPUnit_Framework_Assert::assertRegExp() must be a string Caused by PHPUnit_Framework_Exception: Argument #2 (No Value) of PHPUnit_Framework_Assert::assertRegExp() must be a string

I think this is due to the empty strings that are used for matching.

mc-murphy83 commented 8 years ago

did some more research - it currently looks like that the function "assertSelectOptions" hands in an array instead of a string into PHPUnit_Framework_Assert::assertRegExp() - which in turn causes the Failure, as an array can not easily be transformed into a suitable string respresentation that would allow for comparision. It looks like the Interface / return value used has changed.

giorgiosironi commented 8 years ago

This function is dynamically generated deep down the Selenium 1 driver (that's very old code). I would workaround this by caling getSelectOptions() and asserting the result yourself, but I don't know how to write this in Selenese. If you want to write a Pull Request fixing the problem, what you're looking for is PHPUnit_SeleniumTestCase_Driver::autoGenerateCommands() and PHPUnit_SeleniumTestCase_Driver::assertCommand() methods.