Issue Details (XML | Word | Printable)

Key: SIDE-250
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Shinya Kasatani
Reporter: Dan Fabulich
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Selenium IDE

Formatters: EqualsArray asserts on length, fails to translate TestSelectWindow

Created: 04/Sep/08 10:35 PM   Updated: 07/Sep/08 10:05 PM   Resolved: 07/Sep/08 10:05 PM
Component/s: None
Affects Version/s: 1.0-beta2
Fix Version/s: 1.0


 Description  « Hide

TestSelectWindow makes some verifications of arrays by assuming the Selenese will join the arrays:

verifyAllWindowNames ,
verifyAllWindowNames regexp:myPopupWindow

but EqualsArray attempts to parse the string for commas "," to calculate the length of the array, and then asserts that the array is of the specified length. This breaks the test when you attempt to run it.

I think the fix is to eliminate the length verification altogether...?



Sort Order: Ascending order - Click to sort in descending order
Shinya Kasatani added a comment - 05/Sep/08 01:00 AM

Just eliminating the length assertion would cause an unexpected ArrayIndexOutOfBoundsException if the actual length was shorter than expected, and I think that's not very kind.

I think we should change the code so that it joins the string and matches it against the whole pattern. For instance, | assertAllWindowNames | , | can be translated to a Ruby code like this:

array = @selenium.get_all_window_names
assert_match /^[\s\S]*,[\s\S]*$/, array.join(",")


Dan Fabulich added a comment - 05/Sep/08 04:37 PM

FIxed in IDE revision 476. I'm not an admin of Selenium IDE, so I can't close this issue myself, but that's OK, because I'd like Shinya to review it.


Shinya Kasatani added a comment - 05/Sep/08 06:17 PM

Haven't tested the translated code thoroughly, but the code seems good.
Can you also fix the unit test? It can be run by going to chrome://selenium-ide/content/tests/index.html


Dan Fabulich added a comment - 05/Sep/08 07:38 PM

Er, actually this problem is a bit harder than it looks. TestVerifications retrieves an array including values that contain ",", specifically:

  • first option
  • second option
  • third,,option

A naive join turns this into "first option,second option,third,,option" but Core translates this into "first option,second option,third\,\,option" in htmlutils.js selArrayToString.

To fix this right, I guess we'd have to re-implement selArrayToString in every language, but that sucks.


Dan Fabulich added a comment - 05/Sep/08 07:51 PM

In revision 477 I committed code that did the opposite of what I just suggested. Instead of doing all the hard work of implementing selArrayToString in 7 languages/formatters, I just stripped the escaped commas out of the pattern. This makes the test pass, though it is technically less safe. But I think implementing selArrayToString in the formatter would make all of our other generated code really unnecessarily ugly, and you can always change the test manually later if you want, so I'm sticking with what I've got.


Dan Fabulich added a comment - 05/Sep/08 08:44 PM

oh, and unit tests fixed revision 478.


Shinya Kasatani added a comment - 07/Sep/08 10:05 PM

Looks good, thanks for fixing!