Which actually raises an interesting point: somewhere in the Watir documentation is the notion that the easiest way to find the link is by id--the id= attribute inside the Anchor tag, which apparently is preferred under current markup language standards, or name--the name=  attribute inside the Anchor tag, which is apparently deprecated.  Looking by :text means that if the text on the link changes, the test breaks.  The theory is that an id attribute will be changed less often than the text.  That seems like a reasonable presumption in many cases.  The HTML you use in your example might be part of a tutorial that you're doing, or it might be part of an application that you're testing.  If the latter, you can ask the programmer nicely for more testability by asking for id attributes in the markup.

Michael, since you've offered to write Watir documentation, i thought i should make a few points of minor clarification.

These issues you mention are really not pertinent to the Watir documentation per se. Rather they describe testing principles that true whether you are using Watir or some other tool.

The id attribute indeed tends to be the must useful identifier for testing. This is because, by specification, it is unique on a page. The name attribute is not necessary unique. In some cases, it is proper for two fields to have the same name attribute -- if they do the same thing. A good example would be to suppose that for page design reasons a page had two search fields. Properly they would have the same name, but different id's.

Bret


_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to