form element ids and names and testing

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

form element ids and names and testing

NorbertHartl
Hi,

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:

ajaxId: aSymbol
| accessor |
   ^ String streamContents: [
      :stream|
      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?

thanks,

Norbert


_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: form element ids and names and testing

Dave Bauer
> 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.
>
Hi I usually just lurk here, but I know the general solution to this problem.

This is where using Xpath would be handy or another way to define how
to find the element by first specifying the id of the form, then the
id of the element within the form.

Selenium IDE uses this and its pretty useful.

Dave

_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki
Reply | Threaded
Open this post in threaded view
|

Re: form element ids and names and testing

Lukas Renggli-2
Sorry, I can't help you directly with your problem. Two ideas:

1. Modify Magritte so that you can specify the id manually. Again  
this could potentially lead to duplicated IDs on a single page, if  
you use the same description multiple times.

2. Use a different testing framework. Albatross is well known to work  
with Magritte (and Pier) and has been used for several scenarios.  
Have a look at: http://www.iam.unibe.ch/~scg/Archive/Projects/ 
Brue06a.pdf (Chapter 2). It uses a fuzzy JavaScript search (similar  
to your Xpath idea) to identify the form-element using its label.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch



_______________________________________________
SmallWiki, Magritte, Pier and Related Tools ...
https://www.iam.unibe.ch/mailman/listinfo/smallwiki

smime.p7s (5K) Download Attachment