> ########
> require 'win32ole'
>
> ie = WIN32OLE.new('InternetExplorer.Application')
> ie.visible = true
>
> ie.gohome
>
> ie.Navigate("http://google.com")
> ######################################
>
>
> But now I would like to be able to get/set the value in the google search
text
> box. Can anyone show me how to do this?
> I've been digging through the MSDN stuff, but I'm afraid I'm in a bit over
my
> head here.  :-(

My Internet Explorer Controller lib [http://www.clabs.org/ruby.htm]
encapsulates some of this.

Here's how you'd do it directly:

  require 'win32ole'

  ie = WIN32OLE.new('InternetExplorer.Application')
  ie.visible = true
  ie.gohome
  ie.navigate "http://google.com"

  while ie.busy
  end

  # sometimes this isn't necessary, but I've found in some cases ie.busy
  # returns too quickly. But checking for READYSTATE_COMPLETE by itself
isn't
  # enough, because the browser won't go out of READYSTATE_COMPLETE quickly
  # enough just after a new navigate call.
  READYSTATE_COMPLETE = 4
  until ie.readyState == READYSTATE_COMPLETE
  end

  form = ie.document.forms(0)
  form.q.value = 'cLabs'
  form.submit

With my lib, some of this is simplified:

  require 'cl/iec'

  def form
    IEDomFormWrapper.new(@iec.form)
  end

  VISIBLE = true
  @iec = ClIEController.new(VISIBLE)
  @iec.navigate 'http://www.google.com'
  form.q = 'cLabs'
  form.submit

@iec.navigate automatically calls a wait method that handles the while
ie.busy and readystate nonsense.
form.q doesn't require you to specify the .value on the end.


Chris
http://clabs.org