# IE Automation/Recorder - Watir/Wet

**URL:** <https://www.ruby-forum.com/t/ie-automation-recorder-watir-wet/96832>\
**Category:** Ruby\
**Created:** [January 24, 2006, 10:14pm UTC](https://www.ruby-forum.com/t/ie-automation-recorder-watir-wet/96832 "2006-01-24T22:14:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [January 24, 2006, 10:14pm UTC](https://www.ruby-forum.com/t/ie-automation-recorder-watir-wet/96832/1 "2006-01-24T22:14:26Z")

</div>

Hi,  
I am trying to write a Record and Playback utility for Watir and WET,  
using Ruby and the OLE provision it provides.

My detailed knowledge about IE and DOM is limited though, I am using  
the the code below to capture HTML events by extending the sample code  
at the end of this email.

ev = WIN32OLE\_EVENT.new(ie, ‘HTMLElementEvents2’)  
ev.on\_event {|\*args| html\_event\_handler(\*args)}

I am able to detect clicks on components , focus in /out etc. however I  
am unable to successfully, detect “onchange”.

I am particularly interested in capturing this change so that i can  
determine when the user entered data in fields, comboboxes, text areas  
etc.

Any takers ?  
Thanks and Regards,  
Asif

Sample code you will find relevant

$urls = []  
def navigate(url)  
$urls \<\< url  
end

def stop\_msg\_loop  
puts “IE has exited…”  
throw :done  
end

def default\_handler(event, \*args)  
case event  
when “BeforeNavigate”  
puts “Now Navigating to #{args[0]}…”  
end  
end

ie = WIN32OLE.new(‘InternetExplorer.Application’)  
ie.visible = TRUE  
ie.gohome  
ev = WIN32OLE\_EVENT.new(ie, ‘DWebBrowserEvents’)

ev.on\_event {|\*args| default\_handler(\*args)}  
ev.on\_event(“NavigateComplete”) {|url| navigate(url)}  
ev.on\_event(“Quit”) {|\*args| stop\_msg\_loop}

catch(:done) {  
loop {  
WIN32OLE\_EVENT.message\_loop  
}  
}

puts "You Navigated to the following URLs: "  
$urls.each\_with\_index do |url, i|  
puts “(#{i+1}) #{url}”  
end

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [February 16, 2006, 5:48pm UTC](https://www.ruby-forum.com/t/ie-automation-recorder-watir-wet/96832/2 "2006-02-16T17:48:37Z")

</div>

unknown wrote:

> I am able to detect clicks on components , focus in /out etc. however I  
> am unable to successfully, detect “onchange”.
> 
> I am particularly interested in capturing this change so that i can  
> determine when the user entered data in fields, comboboxes, text areas  
> etc.

I’d be interested to see the solution to this question, too.
