Simple script not working

Hi,

require 'rubygems'
require 'watir-webdriver'

children=[]
count=0
fact=0
5.times do
children<<Thread.new do
    1.times do
    fact+=1
    begin
    br=Watir::Browser.new :ie
    br.goto('some-site')
    br.link(:text,'Sign In').click
    count+=1 if br.text_field(:id,'username').exist?
ensure
    br.close
end
    end
end
end
children.each do |c|
    c.join
end
puts "fact: #{fact} count: #{count}"

Giving me following error:
C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `initialize': No connect
ion could be made because the target machine actively refused it. -
connect(2) (Errno::ECONNREFUSED)
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `open'
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `block in
connect'
       from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
       from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:762:in `connect'
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:744:in `start'
       from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1284:in `request'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:83:in
`response_for'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/default.rb:39:in
`request'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/http/common.rb:40:in
`call'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:598:in
`raw_execute'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:576:in
`execute'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/remote/bridge.rb:189:in
`quit'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/ie/bridge.rb:59:in
`quit'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.26.0/lib/selenium/webdriver/common/driver.rb:166:in
`quit'
       from
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:87:in
`close'
       from focus.rb:17:in `ensure in block (3 levels) in <main>'
       from focus.rb:17:in `block (3 levels) in <main>'
       from focus.rb:9:in `times'
       from focus.rb:9:in `block (2 levels) in <main>'

···

--
Posted via http://www.ruby-forum.com/.

It looks like your browser can't establish a connection. Firewall?

···

--
Posted via http://www.ruby-forum.com/.

I've also seen that error before when the browser is closed in the
middle of doing something. Maybe "br.close" is triggering while the
thread is still doing something?

···

--
Posted via http://www.ruby-forum.com/.

Joel Pearson wrote in post #1087040:

It looks like your browser can't establish a connection. Firewall?

I can see that it opens few ie window and then throws the error. Even on
irb i can atart a browser and go to url etc.. By the way if its the case
of firewall.. Then how can I check that?

···

--
Posted via http://www.ruby-forum.com/\.

Joel Pearson wrote in post #1087112:

I've also seen that error before when the browser is closed in the
middle of doing something. Maybe "br.close" is triggering while the
thread is still doing something?

How can it be triggered without reason?

···

--
Posted via http://www.ruby-forum.com/\.

Joel Pearson wrote in post #1087040:

It looks like your browser can't establish a connection. Firewall?

I can see that it opens few ie window and then throws the error. Even on
irb i can atart a browser and go to url etc..

You may also fall victim of a connection count restriction as is
usually present in client Windows systems.

By the way if its the case
of firewall.. Then how can I check that?

Check firewall logs. Where they reside depends on the firewall used.

Kind regards

robert

···

On Thu, Nov 29, 2012 at 10:32 AM, Prog Rammer <lists@ruby-forum.com> wrote:

--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/

You may also fall victim of a connection count restriction as is
usually present in client Windows systems.

But I am opening only 5 browsers at a time.

Check firewall logs. Where they reside depends on the firewall used.

followed

no logs I found, i mean its blank.

···

--
Posted via http://www.ruby-forum.com/\.

Prog Rammer wrote in post #1087069:

You may also fall victim of a connection count restriction as is
usually present in client Windows systems.

But I am opening only 5 browsers at a time.

How many browsers can you use like this before you experience the error?
If it's consistent then as Robert said, it might well be the connection
count. Don't forget you may have other processes running which can all
add up.

With regard to the browser closing, it's more of a direction to look in
than a specific pointer... try closing the browser manually during
execution and see if the error is exactly the same. You could also add a
rescue and log to see whether every subsequent browser window
experiences the same error.

···

--
Posted via http://www.ruby-forum.com/\.