In the context of Watir itself, however, any of these methods (name, id, text) are equally good. It is only the larger context of specific applications and the practices used to develop them that you can say thatone method may be better than another.
Some of the most valuable writing might be to describe how to do effective automated testing using Watir. Watir allows this key issue of identification method to be explicit and simple, without having to go into window maps or other configuration settings or lengthy tool explanations. One of my primary motivations for developing Watir was to facilitate this kind of writing. But I would hesitate to call this kind of thing "Watir documentation". Consider Mike Kelly's performance testing article. He orginally had his examples written JRobot (i think) but ported them to Watir to increase the accessibility of the article.
BTW, i think where you are taking this is in a direction that by convention goes under the label "best practices".
Bret
On 1/16/06, Michael Bolton <[EMAIL PROTECTED]> wrote:
Thanks, Bret.Even though it's not an issue exclusive to WATIR or its documentation, I'd contend that it's relevant. Many people (partly because of the price, for example) will be coming at test automation for the first time through WATIR. I wouldn't necessarily put this sort of gloss in (say) the entry on the "link" method, but I might put it into an appendix or a footnote. Reasonable?---Michael B.
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Bret Pettichord
Sent: January 16, 2006 2:20 PM
To: wtr-general@rubyforge.org
Subject: Re: [Wtr-general] Link that can not be foundWhich 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
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________ Wtr-general mailing list Wtr-general@rubyforge.org http://rubyforge.org/mailman/listinfo/wtr-general