Scott Hanselman

A Very Poor Man's Vonage Web Service using Watir

July 02, 2006 Comment on this post [13] Posted in Ruby | Watir
Sponsored By

Folks keep calling after 9pm and waking the baby. We use Vonage, and I really wish they had a feature where I could indicate "do not call" times. Alas, they don't. So, then I wished for a Vonage Web Service. Nope.

So, instead here's a Watir script, recorded with a early version of Michael Kelly and John Hann's port of WatirMaker to Ruby (via "ruby watirmaker.rb > myscript.rb") then edited to taste.

#Enable Instant Forward to Voice Mail
require 'watir'
include Watir

ie =
ie.goto( '' )

ie.text_field( :name, 'username' ).set( 'username' )
ie.text_field( :name, 'password' ).set( 'password' )
ie.button( :name, 'submit' ).click,"Features").click

ie.button( :name, 'callForwardingButton' ).click

ie.select_list( :name, 'callForwardingSeconds' ).select( 'Instantly' )
ie.text_field( :name, 'singleAddress' ).set( '15035551234' )

ie.button(:value,'Enable').click,"Log Out").click

And the disable...

require 'watir'
include Watir

ie =
ie.goto( '' )

ie.text_field( :name, 'username' ).set( 'username')
ie.text_field( :name, 'password' ).set( 'password' )
ie.button( :name, 'submit' ).click,"Features").click

ie.button( :name, 'callForwardingButton' ).click

ie.button(:value,'Disable').click,"Log Out").click

These now run on a schedule in my house using the Windows Scheduler. If you run them like 'ruby enable.rb -b' they run in the background and you'll never see Internet Explorer.

About Scott

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.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 02, 2006 11:48
Awesome and amazing hack. I'm convinced now most anything can be mashed, smashed, hacked. I love it. My baby's due the 26th of July. Could make use of this soon.

Thanks, Scott.
July 02, 2006 12:22
Awesome. On the topic of ruby, have you seen Ruby goodness in the comfort of
July 03, 2006 4:37
James - thanks for the pointer! Blogged!
July 03, 2006 17:08
The watirmaker.rb link does not seem to work...
July 03, 2006 20:23
This is one of those times where I just had to slap my head and think "Why in the hell didn't I think of that?"
Thanks, Scott. I'll be putting this one to good use.

July 04, 2006 0:48
July 04, 2006 1:23
Sleek, Simple and Superb.
you may want to give yourself a 5 minute latency, as I doubt the change is real time.

July 05, 2006 22:54
VoicePulse has the Do Not Disturb feature, and it will come in very handy when our newborn arrives.

Hard to believe Vonage hasn't implemented this yet. Nice workaround, though.
July 17, 2006 3:18
I (finally) got around to trying this. I'm getting an exception when it goes to click on the callForwardingButton. It says it can't find it. Any suggestions? I looked in the HTML of the page, and its there. Here's the actual error message...

c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:1928:in `assert_exists': U
nable to locate object, using name and callForwardingButton (Watir::Exception::U
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:2009:in `clic
from C:/Documents and Settings/Tim/Desktop/test2.rb:24
July 18, 2006 8:54
Tim, not sure what to tell you. It works here. That error says there's no button on the page called "callForwardingButton."

Is there?

I do know that on Firefox the Enable button is named "Save Changes." Vonage is doing some kind of sniffing.
July 18, 2006 22:57
I looked at the page that was left open after the script crashed, and in the source, the button exists. It also appears the the script ALWAYS waits until the page is 100% loaded before continuing. If this is the case, then there's no reason I can think of that could cause it to fail.... I recorded the script myself.

I was running it on my laptop downstairs (older box runnin win2k), and I don't think I tried it on the computer upstairs (MCE2k5). Would the version of IE make a difference? I'll try to play with it some more tonight. On the computer upstairs as well as my work laptop. I can't play with it here as our admins are a bunch of nazis and have vonage websensed.
July 18, 2006 23:09
Try using my script and not a recorded one...
July 19, 2006 6:51
I'm not sure quite what this means, but instead of,"Features").click
the recorded script wound up with
ie.document.all[ '85' ].click

They both go through to the features page, but when it used the document.all method, it couldn't find the callForwardingButton.

Either way, it works now. Thanks!

(For the record, I started with your script, but didn't have watir installed right, so I gave up on that initially. I wanted to automate something slightly different, so I recorded my own.)

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.