From: Justin Bailey Date: 2006-06-28T03:15:38+09:00 Subject: Re: how to wrap methods of WIN32OLE objects ------=_Part_27549_13769780.1151432135542 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 6/27/06, Xavier Noria wrote: > > I am doing screen-scraping with Explorer: Have you looked at the WATIR project (http://wtr.rubyforge.org/)? It's intended as a way to test web applications on the client-side but it also scripts Internet Explorer very nicely. I bet it will even give you access to the DOM (plus a whole lot more). Sorry to not answer your question directly, but you may want to explore it and determine if you are reinventing the wheel. but it turns out that @ie is an object of class WIN32OLE that has > no :Navigate method (so the program dies in that @ie.method > (:Navigate)). Perhaps this has something to do with late binding. Do > you know any way to do that? To address your code specifically, you can add methods to any object this way: # Add a method to @ie object. Untested! class << @ie def nav_and_wait(url) @ie.Navigate(...) wait_for_completion end end Because of the way those COM objects are built, you may have to add this method to each instance returned from WIN32OLE.new but that's not too hard to do either. Note that I'm not overridding Navigate - I'm just adding a new method that wraps the call. Justin ------=_Part_27549_13769780.1151432135542--