form element ids and names and testing
norbert at hartl.name
Tue Jul 31 12:45:56 MEST 2007
I'm a user of seaside testing. SeasideTesting provides two
methods for accessing form elements. It's by index and by
element id. Requesting by index is too error prone as the
change of the order of form elements breaks the test.
Requesting by id is rendered impossible by using Magritte.
The ajaxId: stuff includes the hash of an object and is not
predictable when used inside a test.
I changed ajaxId: in MAComponent to use the following:
| accessor |
^ String streamContents: [
accessor := self description accessor.
[ accessor respondsTo: #next ] whileTrue: [
stream nextPutAll: accessor accessor readSelector.
stream nextPut: $..
accessor := accessor next
stream nextPutAll: accessor readSelector.
This gives you the name of the selector as id and for nested
descriptions you get nestedObjectSelector.selector. Therefor
the ids per object are unique and are easily used in SeasideTesting.
But my colleague reminded me that this only works if I have a
single form on the page. He said the id has to be unique across
the whole page. So my approach is bit critical.
Is there anybody who uses SeasideTesting for testing magritte
components? And if yes how do you do that?
More information about the smallwiki