« Capturing Video a Web Camera using WIA -... | Main | Sapphire In Steel - Ruby within Visual S... »

A Very Poor Man's Vonage Web Service using Watir

Posted 2006-07-01 10:49 PM in Ruby | Watir.

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.new
ie.goto( 'http://www.vonage.com/' )

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

ie.link(:text,"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

ie.link(:text,"Log Out").click
ie.close

And the disable...

require 'watir'
include Watir

ie = IE.new
ie.goto( 'http://www.vonage.com/' )

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

ie.link(:text,"Features").click

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

ie.button(:value,'Disable').click

ie.link(:text,"Log Out").click
ie.close

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.

Tracked by:
http://www.johnarmitage.net/word/PermaLink,guid,37e6e2e2-f277-400f-b832-fc68adac... [Pingback]


Saturday, July 01, 2006 11:48:35 PM (Pacific Standard Time, UTC-08:00)
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.
Sunday, July 02, 2006 12:22:01 AM (Pacific Standard Time, UTC-08:00)
Awesome. On the topic of ruby, have you seen www.sapphiresteel.com? Ruby goodness in the comfort of vs.net
street
Sunday, July 02, 2006 4:37:25 PM (Pacific Standard Time, UTC-08:00)
James - thanks for the pointer! Blogged!
Scott Hanselman
Monday, July 03, 2006 5:08:20 AM (Pacific Standard Time, UTC-08:00)
The watirmaker.rb link does not seem to work...
Justin
Monday, July 03, 2006 8:23:58 AM (Pacific Standard Time, UTC-08:00)
NICE!
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.

Monday, July 03, 2006 12:48:18 PM (Pacific Standard Time, UTC-08:00)
Fixed.
Scott Hanselman
Monday, July 03, 2006 1:23:38 PM (Pacific Standard Time, UTC-08:00)
Sleek, Simple and Superb.
you may want to give yourself a 5 minute latency, as I doubt the change is real time.

Sat
Satish Balusa
Wednesday, July 05, 2006 10:54:50 AM (Pacific Standard Time, UTC-08:00)
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.
Neill
Sunday, July 16, 2006 3:18:05 PM (Pacific Standard Time, UTC-08:00)
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
nknownObjectException)
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.4.1/./watir.rb:2009:in `clic
k'
from C:/Documents and Settings/Tim/Desktop/test2.rb:24
Tim Coker
Monday, July 17, 2006 8:54:58 PM (Pacific Standard Time, UTC-08:00)
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.
Scott Hanselman
Tuesday, July 18, 2006 10:57:37 AM (Pacific Standard Time, UTC-08:00)
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.
Tim Coker
Tuesday, July 18, 2006 11:09:10 AM (Pacific Standard Time, UTC-08:00)
Try using my script and not a recorded one...
Scott Hanselman
Tuesday, July 18, 2006 6:51:49 PM (Pacific Standard Time, UTC-08:00)
I'm not sure quite what this means, but instead of
ie.link(:text,"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.)
Tim Coker
Comments are closed.

Contact

Sponsors

Hosting By

Hot Topics

Tags

Calendar

<November 2009>
SunMonTueWedThuFriSat
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

Archives

November, 2009 (5)
October, 2009 (19)
September, 2009 (11)
August, 2009 (12)
July, 2009 (21)
June, 2009 (26)
May, 2009 (16)
April, 2009 (13)
March, 2009 (17)
February, 2009 (17)
January, 2009 (18)
December, 2008 (32)
November, 2008 (17)
October, 2008 (22)
September, 2008 (16)
August, 2008 (14)
July, 2008 (25)
June, 2008 (19)
May, 2008 (17)
April, 2008 (17)
March, 2008 (26)
February, 2008 (21)
January, 2008 (28)
December, 2007 (19)
November, 2007 (17)
October, 2007 (31)
September, 2007 (39)
August, 2007 (37)
July, 2007 (43)
June, 2007 (37)
May, 2007 (32)
April, 2007 (38)
March, 2007 (29)
February, 2007 (46)
January, 2007 (31)
December, 2006 (27)
November, 2006 (31)
October, 2006 (32)
September, 2006 (39)
August, 2006 (34)
July, 2006 (40)
June, 2006 (18)
May, 2006 (31)
April, 2006 (34)
March, 2006 (30)
February, 2006 (38)
January, 2006 (44)
December, 2005 (19)
November, 2005 (34)
October, 2005 (24)
September, 2005 (37)
August, 2005 (20)
July, 2005 (24)
June, 2005 (33)
May, 2005 (16)
April, 2005 (22)
March, 2005 (34)
February, 2005 (15)
January, 2005 (37)
December, 2004 (28)
November, 2004 (30)
October, 2004 (34)
September, 2004 (22)
August, 2004 (34)
July, 2004 (18)
June, 2004 (64)
May, 2004 (49)
April, 2004 (21)
March, 2004 (29)
February, 2004 (29)
January, 2004 (36)
December, 2003 (25)
November, 2003 (24)
October, 2003 (59)
September, 2003 (42)
August, 2003 (24)
July, 2003 (44)
June, 2003 (29)
May, 2003 (21)
April, 2003 (30)
March, 2003 (27)
February, 2003 (47)
January, 2003 (50)
December, 2002 (31)
November, 2002 (38)
October, 2002 (44)
September, 2002 (15)
May, 2002 (2)
April, 2002 (4)

Google Ads