Re: [Watin-development] Patch to find field elements by near by text
Brought to you by:
jvmenen
From: Jeroen v. M. <je...@va...> - 2007-11-19 21:59:34
|
Hi Jeremy, Thanks for sending in your ProximityConstaint patch (it makes incorporating contributions so easy)! Regarding adding a method to the Find class, my 2 cents would be Find.Near() instead of Find.ByProximity. Then syntax would read something like: ie.TextField(Find.Near("User name")).TypeText("JohnD"); I'm going through your code at the moment. Love the naming of your tests methods already! Jeroen Jeremy Wadsack schreef: > Thanks Daaron. That Find.ByProximity is a great suggestion. I actually > started down that path, but of course needed access to the DOM and the > page to complete it. I working through the details I forgot that I > could go back and do that now. I'll add that method and post an > updated patch sometime tonight (maybe). > > I'll consider the Left, Right, Above, Below option. I'd like to make > it smart enough not to have this. If I can come up with test cases > where it does /not/ get the correct field and needs this hint then > I'll add it as that's really the most logical way to do it. > > -- > Jeremy Wadsack > Seven Simple Machines > www.sevensimplemachines.com <http://www.sevensimplemachines.com> > > On Nov 18, 2007 7:27 AM, Daaron Dwyer <da...@gm... > <mailto:da...@gm...>> wrote: > > I think it's a great idea, with a few modifications. > An extremely small addition of a Find method would make it more > seamless, like: > Button btn = ie.Button(Find.ByProximity("User Name",Right)); > > You probably noticed my other change-- having the developer tell where > the target item should be (left, right, above, or below). The search > method may get simpler with this addition. > > > On Nov 17, 2007 6:26 PM, Jeremy Wadsack <jer...@gm... > <mailto:jer...@gm...>> wrote: > > One of the problems I've seen with our automated web application > testing > > (with any library) is that the underlying HTML can change and it > breaks the > > test. We've been struggling with this through our other tools > including > > making changes to our programming to support testing, etc. > > > > In thinking about it however, it seemed to me that a visual > testing tool > > should work just like the human. If I am looking at a page with > Username and > > Password and associated fields, I usually can figure out what > the labels are > > for those fields -- even if the labels are not marked as HTML > labels. And I > > certainly, as a human tester, don't need to look at the HTML to > figure out > > where to enter my username or password. > > > > I took this approach and built a new ProximityTextConstraint > class that uses > > some geometry and measurement of text and elements on the page > to try to > > find the best field for given text. I've attached a patch file > with the > > changes including a suite of unit tests to prove the case. > > > > Basically, you can now search for a field element on a page with > code like > > this: > > > > TextField inputUsername = ie.TextField(new > > ProximityTextConstraint("User Name")); > > > > > > It's not complete - although I couldn't build a test case to > prove it I > > think there are cases where it might grab the wrong element when > they are > > closely aligned in a stack of fields and labels. I've annotated > my suggested > > approach in the code comments. > > > > Any feedback on this would be greatly appreciated. > > > > Also included are some minor changes to the code comments in a > few places > > where I needed more information. > > > > > > -- > > Jeremy Wadsack > > Seven Simple Machines > > www.sevensimplemachines.com <http://www.sevensimplemachines.com> > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2005. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > ------------------------------------------------------------------------ > > _______________________________________________ > Watin-development mailing list > Wat...@li... > https://lists.sourceforge.net/lists/listinfo/watin-development > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.5.503 / Virus Database: 269.16.0/1135 - Release Date: 16-11-2007 22:58 > |