<Rant>
I am going to take the second part first. For me, right now, today, blogs (at least this one) are not nearly as cool as wikis. I keep a nice password protected wiki, where I track spack++ stuff. The fact that I am writing a blog now makes me think that I can take the password protection off, but there you go. I started my wiki back when a friend and I were kind of in stealth mode on some shopping stuff, but I think that nearly everything we were working on is now live. I think holaservers is gonna be awesome, but the linking from the points that I described before could make shopthar stuff explode.
Yesterday, I spent a good hour writing the post I am about to rewrite. WordPress has drafts and saves them as you go along, but so far as I can tell, once you publish, your drafts go away. I was all done with a, for me, pretty rocking post when I noticed the formatting was off. I went in, changed the formatting, clicked I think Save and only my last paragraph remained. After some searching, including getting google desktop going on my computer, I couldn’t find my post. Gone. Such things used to happen in a non-AJAX world, but now? Why? Why not take snapshots as folks are editing, and anything with a different md5 gets a different entry that you keep pretty well forever. Oh, already “published”? Who cares? Keep it around. Generally, we’re talking about text. Yeah, text. Can store a gig of it for fifteen cents a month at amazon. That’s a lot of blog posts. Or if my Google Apps request goes through, I could store 500 megs of it for free. Text! Who cares? Keep a snapshot per minute. If I run out of space, let me delete some drafts. How much time do folks spend editing their blog posts? Actually making changes? I used to write emails with something like EditPadPro open and paste my email in their every so often. I guess those days are back.
PbWiki on the other hand I think does just what I would like. Keep version as I go, let me compare them and roll back to them.
</Rant>
Turns out selenium rulz! Did I mention that I pretty well hate retyping stuff. I feel like I am being a little insincere since I have already written the stuff. Occasionally I have to do it with code and it just kind of irks me. I will now try to really end my rant.
Some few years ago, I took a “vacation” from work to go in to work and work on HTTP::Slap. HTTP::Slap aimed to walk web pages, helping me log into espn and the like. Was pretty into espn’s baseball challenge and needed some help with automated team changes. I got HTTP::Slap to the point where I accept and post back cookies, submit hidden tags from the forms I was posting, post via https, etc. A year or two later, I discovered WWW::Mechanize and don’t think I ever worked on HTTP::Slap again. Guess I should have looked around a bit. Live and learn.
Just a couple years ago, I went to OSCON and heard a talk about selenium. For whatever reason, I didn’t think it was worth pursuing. Yesterday when reviewing the slides I can’t really see what voter feature I was waiting for, but there you go.
Just last week, a coworker, who I think likes to remain off the grid was trying out some holaservers stuff and it didn’t work in ie. “That’s weird”, I thought. Especially since I had made nearly no effort to get it all to work in ie, and I had had ie compatibility problems in the past. I have desire for holaservers to work in ie, but not much desire to test every javascripty thing in both firefox (where I develop) and ie (what people use). I remembered selenium and decided to have a look. At the end of the first night, I had some basic crawling working. I started by exporting an html page from the fine selenium IDE, would parse the html in perl and then pass the commands over to WWW::Selenium (which I think should be version 1.15 as there is a 1.14). I liked walking through a path with the IDE, but figured that I would want to do unit tests in perl. Eventually I just did everything in perl. I started to use EPIC, a perl plugin for eclipse and could just debug through, which was pretty well just as good. Little shout out to EPIC. One of my favorite features of eclipse is being able to hit <ctrl>-<shift>-f and apply some formatting rules. If you have perltidy installed, EPIC will do that for you as well.
After a bit of work, I can walk through my site using selenium, and I got things working in ie, firefox, opera and safari. Just had a few issues.
- Cross site scripting strikes again. I had been blogging about it back in the day, I could have written about using mod_rewrite to overcome some cross site problems. See, my stuff starts on holaservers.com and goes to my.holaservers.com; cross site scripting shall we say. I divided my script into pre-login and post-login chunks and launched separate browsers for each.
- During login, I bounce, via javascript, with an auth in the query string. To have my perl script mimic this behavior, I need that bounce url. I set a cookie (selenium=1) and if I have that cookie, I alert the url, which selenium then grabs and bounces to. Works like a champ. Hopefully no users will ever see it.
- Think the main cross browser problem I had came from me using my own naive implementation of ajax. If you look, I don’t really do much, but for some reason, ie wouldn’t get my callbacks. I switched over to the YUI implementation and everything started working. I think I wrote mine before yui was around, or at least before I had heard of it, but again, live and learn.
- Safari for windows is slow. The other browsers would run the tests (which as above, launches a browser twice) in about 30 seconds. Safari on three runs did 108, timeout exceeded and 111 seconds. Pretty good for the world’s fastest browser.
I posted my test script here, and for some reason, the formatting got hosed, darn it. I even went through and fixed it, though to no avail.
Enjoy!
Earl