0

我想实现 watirgrid,但我无法做到这一点,每次我遇到与控制器和提供程序启动过程相关的错误时,还有互联网上的所有示例,它们都没有工作。

任何人都可以帮我实现这一点,带有步骤的完整运行示例将是一个很大的帮助。

我正在尝试这段代码:

require 'rubygems'
require 'watirgrid'
require 'watir'
require 'watir-webdriver'

# setup a controller on port 12351 for your new grid
controller = Controller.new(:ring_server_port => 12351, :loglevel => Logger::ERROR)
controller.start

# add a provider to your grid
# :browser_type => 'webdriver' if using webdriver or
# :browser_type => 'ie' if using watir...
provider = Provider.new(:controller_uri => 'druby://127.0.0.1:11235',
                        :ring_server_port => 12351,
                        :loglevel => Logger::ERROR, 
                        :browser_type => 'webdriver')
provider.start

# connect to the grid and take all providers from it (this time only one)
grid = Watir::Grid.new(:ring_server_port => 12351, :ring_server_host => '127.0.0.1')
grid.start(:take_all => true)

# for each provider on the grid, launch a new thread to start multiple browsers
threads = []
grid.browsers.each do |browser|
  threads << Thread.new do
    p browser[:hostname]
    p browser[:architecture]
    p browser[:browser_type]
     # in this case we are starting a new IE browser
    b = browser[:object].new_browser(:ie)
    b.goto("http://www.google.com")
    b.text_field(:name, 'q').set("watirgrid")
    b.button(:name, "btnI").click
  end
end
threads.each {|thread| thread.join}

我得到的错误是

DRb::DRbConnError: druby://127.0.0.1:11235 - #<Errno::ECONNREFUSED: No connection could  
be made because the target machine actively refused it. - connect(2)>
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:736:in `rescue in block in open'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:730:in `block in open'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:729:in `each'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:729:in `open'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1191:in `initialize'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1171:in `new'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1171:in `open'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1087:in `block in method_missing'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1105:in `with_friend'
  from C:/Ruby192/lib/ruby/1.9.1/drb/drb.rb:1086:in `method_missing'
  from C:/Ruby192/lib/ruby/gems/1.9.1/gems/watirgrid-1.1.5/lib/provider.rb:141:in `start'
  from (irb):44
  from C:/Ruby192/bin/irb:12:in `<main>'
irb(main):045:0>
4

1 回答 1

-1

我遇到了同样的问题,我通过更改成功启动了提供程序

controller_uri

controller_uri => 'druby://machineIPAddress:11235'
于 2014-05-09T05:27:12.797 回答