I also ran into this problem a while back.  After trying the same
options you listed, I wound up working around it by using Windows task
scheduler to run the scripts that needed the attach method.  It was a
bummer to not be able to manually start the scripts from a remote
machine whenever I wanted, though.

A while later, I was introduced to the Ruby gserver library.  A quick
test seems to show that the attach method works fine when I remotely
start a Watir script using a little gserver-based server.  So, this
might solve the problem for you too.

Below I've pasted my gserver script.  When this is run, it loops
forever listening on 0.0.0.0 port 10001.  So, if you open a browser on
an external machine and point it at http://[your-hostname]:10001, it
should execute the serve() method and the "system('ruby
attach_test.rb')" statement inside it.

The script expects attach_test.rb in the same dir as the gserver
script.  Also, I suppose you'd need to set up a Windows firewall
exception if you have it enabled.

watirserver.rb:
======================
# Executes 'attach_test.rb' whenever someone connects to port 10001

require 'gserver'

class WatirServer < GServer
  def initialize(port=10001, host='0.0.0.0')
    super(port, host, Float::MAX, $stderr, true)
  end
  def serve(io)
    system('ruby attach_test.rb')
  end
end

server = WatirServer.new
server.start
server.join
======================


attach_test.rb :
======================
require 'watir'

ie = Watir::IE.new.goto('www.google.com')
ie2 = Watir::IE.attach(:title, /Google/)
ie2.text_field(:name, 'q').set('Ruby')
ie2.button(:name, 'btnG').click
======================
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to