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:inopen’
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:intimeout’
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:inconnect’
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:instart’
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:inresponse_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:incall’
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:inexecute’
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:inquit’
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:inclose’
from focus.rb:17:in ensure in block (3 levels) in <main>' from focus.rb:17:inblock (3 levels) in ’
from focus.rb:9:in times' from focus.rb:9:inblock (2 levels) in ’

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

Joel P. 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?

On Thu, Nov 29, 2012 at 10:32 AM, Prog R. [email protected]
wrote:

Joel P. 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

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?

Joel P. 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?

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
http://technet.microsoft.com/en-us/library/cc753781(v=ws.10).aspx
no logs I found, i mean its blank.

Prog R. 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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs