I have blogged before about using Powershell as a web testing harness before, but recently I started doing something a little different that has made it even more useful and simple before: jQuery.
Powershell gives you access to the HTML DOM from IE, but as we all know this is a bit primitive. Essentially, if there are objects on the page with which you want to interact and those objects do not have an id associated with them, you're writing some fragile, painful looping code to traverse the DOM sometimes.
So, I got to thinking: if the developer won't add ids to the objects (and their reason was sound), was there an easy way *I* could add them? I realize there are some fundamental problems with this idea:
1) the method might break functionality, depending on how I do it. This would introduce "phantom bugs" into the web app. Not good.
2) I run the risk of altering existing id values, which would be disastrous.
3) I am essentially changing the conditions of the test, regardless of breakage..
So, I decided that I'd accept these issues/risks and give my idea a shot.
Since we are loading jQuery on every page of our app already, all I needed to do was figure out a way to use jQuery to select and modify the objects with which I wish to interact.
I have a working prototype, but I want refine the example further before I post it.
More to come...