List Info

Thread: code structure problem




code structure problem
user name
2007-04-11 06:02:10
Hi,

I have a bit of a code structure problem, I wonder if
any-one can help?

I instantiate the IE class and assign it to a global object

$ie = Watir::IE.new
def browser;$ie;end

I go through an Object Map using Module constants

module Login
  USERNAME = browser.text_field(:name, 'user_name')
  PASSWORD = browser.text_field(:name, 'password')

 # etc

end

I use Test::Unit setup and teardown methods

  include Login

  #the setup method is executed before each test method
  def setup
    browser.goto('http://missiontes
ting.updatelog.com')
    browser.bring_to_front
    browser.maximize
  end

  #the teardown method is executed after each test method
  def teardown
   browser.close
  end

  However, after the first test method, the browser is
closed,
  so Ruby cannot find the goto method (above in setup)

  How best can I structure this?

  aidy
_______________________________________________
Wtr-general mailing list
Wtr-generalrubyforge.org
htt
p://rubyforge.org/mailman/listinfo/wtr-general

Re: code structure problem
country flaguser name
United States
2007-04-11 09:15:57
instantiate $ie in setup or don't close browser in teardown
- when you
close browser, $ie is closed (because browser is just a
reference to the
same object) and thus unavailable going forward.

  #the setup method is executed before each test method
  def setup
    browser.goto('http://missiontes
ting.updatelog.com')
    browser.bring_to_front
    browser.maximize
  end

  #the teardown method is executed after each test method
  def teardown
   browser.close
  end

  However, after the first test method, the browser is
closed,
  so Ruby cannot find the goto method (above in setup)

  How best can I structure this?

  aidy
_______________________________________________
Wtr-general mailing list
Wtr-generalrubyforge.org
htt
p://rubyforge.org/mailman/listinfo/wtr-general
_______________________________________________
Wtr-general mailing list
Wtr-generalrubyforge.org
htt
p://rubyforge.org/mailman/listinfo/wtr-general

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )