Time Saver - Using Watir as a Startup Program in your ASP.NET Projects
Often when you're inching forward within an ASP.NET project you'll find yourself repeating actions over and over again to get to a certain page, often three or four actions in to the application. As someone who hates repetitive actions this is what I do.
(These examples are in VS2005, but will work in VS2003, although the property dialogs have changed)
I use Watir to automate the clicks that will get me to where I'm going and set my Watir script to startup when I press F5 to start my project debugging.
In this example, I have a script called justsignon.rb that signs on, visits the customer's accounts page, then goes to their Account History page. It's that page that I am currently debugging so I want to automatically show up there in a certain state when I start debugging.
class WatirMakerRecorded < Test::Unit::TestCase
ie = IE.new
ie.link(:text, "Account History").click
#UPDATE - the debugger will detach if the spawned process ends, so wait for ENTER
As I move forward in my development process I use different scripts to get me to different states. This easily adds up to as much as 15 minutes to a half hour of rote "monkey clicking" that is usually wasted time.
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
First, I use the Session State Server Service during development (and in Production). In development, I point web.config to use my local machine as the session state server. This allows my sessions to be retained when I rebuild, so long as I use the same browser window.
Second, I never hit F5 to start debugging. Rather, I hit Debug->Processes... select aspnet_wp.exe, Attach, OK, Close. This attaches the debugger to the already-running worker process. Then I just go back to my already-open browser (IE usually) and continue what I was debugging. Now, this part sounds painful, but... I have Alt-P mapped to fire off the 'Processes' command in VS.NET. And most often, aspnet_wp.exe is the first item in the processes list, and it's already selected. When that's the case, I simply need to press Enter 3 times (as quickly as I can), and I'm set. Bastard acrobat sometimes steals the #1 spot, causing me to hit the down arrow once in the middle... but I can hit Alt-P, Enter, Enter, Enter very quickly and viola-I'm debugging.
I don't remember the last time I used the traditional Debug->Start process for debugging an ASP.NET project.
I've taken the liberty to mention this post on my poor-cousin of a blog (!)
Don't know how you do it, and do it, and do it....
I already use SlickRun with a few choice commands set up for most quick debugging. Making a separate command for editing the rb file makes it really easy to keep updated. It makes logging in as different users and going different places really easy.
I also use Watir and unit test cases for more involved debugging. That allows me to put assertions in while getting to the page I want, and I can keep it if it ends up as a useful functional test of the fix.
This takes it to the next level by making it that much faster to compile and run.
I think you may have one little issue with this snazzy Watir script. Once the ruby script completes, doesn't the ruby command window close and disengage the debugger automatically?
I'm running a similar script in VS2003, and I ended up putting an extra "gets" statement at the end of my script so that I could keep the debugger attached to the process.
Although having some problems, setting it up as that, ruby runs but never executes the script and the command window disappears too quickly to see that the problem is. Any help?
Comments are closed.