Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8257849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T02:20:25+00:00 2026-06-08T02:20:25+00:00

Updated: I’m running the code below to execute my sample test cases: (Windows 7,

  • 0

Updated:

I’m running the code below to execute my sample test cases: (Windows 7, Watir 3.0.0, Watir-webdriver-0.6.1)

require "watir-webdriver"
require 'test/unit'

class Teste1    
    $var = Watir::Browser.new :chrome       
    def met1
        $var.goto 'google.com'
        $var.text_field(:name, "q").set 'sample'
        $var.button(:name =>'btnG').click
    end     
end

class Teste2 < Test::Unit::TestCase 
    $test = Teste1.new
    def test_gomet1
        $test.met1()
    end     
end

The browser opens but the script throws the following error:

test_gomet1(Teste2):
Errno::ECONNREFUSED: No connection could be made because the target machine actively refused it. - connect(2)
   C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:82:in `response_for'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/default.rb:38:in `request'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:598:in `raw_execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:576:in `execute'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/remote/bridge.rb:99:in `get'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.25.0/lib/selenium/webdriver/common/navigation.rb:14:in `to'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:63:in `goto'
maisum.rb:11:in `met1'
maisum.rb:21:in `test_gomet1'

Can anyone help me on that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T02:20:27+00:00Added an answer on June 8, 2026 at 2:20 am

    I cannot get that exception for the test_closeVar test, however I can reproduce it for your other two tests. You get that exception when you try to interact with the browser after it has been closed.

    When using Test::Unit, keep in mind that the tests run in alphabetically order. Therefore your test_closeVar test will close the browser before test_gomet1 and test_gomet2 even run. test_gomet1 and test_gomet2 will throw that exception because the browser is closed.

    As a quick fix, you could add numbers to the test names to get them to run in a specific order.

    The long term fix though is really to make your tests independent so that order does not matter.

    Update

    A couple of observations:

    • The problem occurs using Selenium-Webdriver, so not a Watir-Webdriver specific issue.
    • The script runs fine in Firefox, so it might be a chromedriver specific issue.

    Workaround: It seems like the chrome browser does not like being declared outside the test case. I do not understand why, but the quick fix is to declare the browser in the setup of the test case. If you want to use the same browser for each test, you can just declare it if it does not already exist.

    The following will run (though I would suggest cleaning it up to reduce the usage of global variables):

    class Teste1    
        def met1
            $var.goto 'google.com'
            $var.text_field(:name, "q").set 'sample'
            $var.button(:name =>'btnG').click       
        end     
    end
    
    class Teste2 < Test::Unit::TestCase 
        def setup()
            unless defined?($var)
                $var = Watir::Browser.new :chrome       
            end
            $test = Teste1.new()
        end
    
        def test_gomet1
            $test.met1()
        end     
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Updated below . The following is the entire code I have in my main.cpp:
UPDATED: Added some sample code to help clarify. Hi, Feel like this shouldn't be
UPDATED: when i executing Unit Test project and then it will return Was unhandled
Updated question, see below I'm starting a new project and I would like to
UPDATED See post #3 below. There is a need to upload a file to
-------UPDATED------------------------------------- In this class i do the calculations: ... ArrayList<Double> final_cores =new ArrayList<Double>(); ...
[Updated below] I am having a problem connecting to a MySQL database using a
UPDATED: 06.29.10 Here's the code I'm using so far. I'm really close after searching
--Updated Code to make it...more simple-- Kind of a strange situation, according to w3schools
Updated code: function getElements() { var x=document.getElementsByTagName("option"); var el = document.getElementById('selectDept'); el.onmouseover = function(

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.