[Wtr-general] 'ie.close' or 'ie.close if ie'

matt forum-watir-users at openqa.org
Tue Mar 6 19:27:22 EST 2007


Hello,

I am new to Ruby/watir ... so forgive me plz.

After reading through the "ie window" threads, I am still puzzled how to create a single ie browser for my test.  Questions:

1) If there is one browser instance for the test, how is one to close the browser at the end of the test?  Should a test_closebrowser() method be created at the end?

2)  When using this example, I am finding that the @ie instance variable is nil at the beginning of each test method.  Isn't the instance variable supposed to be persistent throughout all of the tests?

3) I looked through the examples, but couldn't find an example of the IE.attach() method.  Should I keep track of the window handle when the instance is created and just reference that throughout the test?

Thanks in advance



Here is a simple example

require 'watir'
require 'test/unit'

class My_TestCase < Test::Unit::TestCase

  # Instance variables
  @ie = nil

  def test_01_initialtest
    # create a new browser for the test (if necessary)
    @ie = Watir::IE.new if @ie == nil

    # do some work ...
  end

  def test_02_secondtest
      # create a new browser for the test (if necessary)
     @ie = Watir::IE.new if @ie == nil

    # do some work ...
  end
end
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6562&messageID=19604#19604


More information about the Wtr-general mailing list