Add_assertion' called for nil:NilClass errror when testing

This @browser is defined in the login method
@browser=Selenium::Client::Driver.new(“localhost”, 4444, “*chrome”, $url
, 10000);

class CrudDContent<Test::Unit::TestCase
def initialize()
login(“browser_name”)
end#initialize()

def test_createdc()
assert(@browser.element?($x_xpath))#the test fails at this assert
end#test_createdc()

end#CrudDContent<Test::Unit::TestCase

When ever I run this program, I get the error :

C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/testcase.rb:125:in
add_assertion': private methodadd_assertion’ called for nil:NilClass
(NoMethodError)
from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:494:in
_wrap_assertion' from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:61:inassert’
from ./content.rb:6:in `test_createdc’
from Driver.rb:8

Can someone take a look, I am out of ideas!

Fixed, I needed to add the initalize the test methods after I called
them

dc=CrudDContent.new()

def initialize(dc)
super(dc)
end #def initialize(dc)

dc.test_createdc()

Arti S. wrote:

This @browser is defined in the login method
@browser=Selenium::Client::Driver.new(“localhost”, 4444, “*chrome”, $url
, 10000);

class CrudDContent<Test::Unit::TestCase
def initialize()
login(“browser_name”)
end#initialize()

def test_createdc()
assert(@browser.element?($x_xpath))#the test fails at this assert
end#test_createdc()

end#CrudDContent<Test::Unit::TestCase

When ever I run this program, I get the error :

C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/testcase.rb:125:in
add_assertion': private methodadd_assertion’ called for nil:NilClass
(NoMethodError)
from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:494:in
_wrap_assertion' from C:/RubyInstall/ruby/lib/ruby/1.8/test/unit/assertions.rb:61:inassert’
from ./content.rb:6:in `test_createdc’
from Driver.rb:8

Can someone take a look, I am out of ideas!

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