TypeError: nil is not a symbol error when running tests

TypeError: nil is not a symbol error when runing test.

Has anyone seen this error before? I have added the method that gives
me trouble below

Running the Class :

s_name=“ItemName”+Time.Now()

dc=CreateItem.new(s_name)

with the definition

class CreateItem< Test::Unit::TestCase

attr_accessor :s_name
s_name=“SH Test”

def setup

login(“Browser”)

end#setup

def initialize(name)
@s_name=name
end #def initialize(dc)

#~ #Test to create a Item
def test_createdc(name)
#@$browser.open(“https://index.html”)
@s_name=name

      s
      xpath="//div[@class='view

container]//label[contains(text(),‘#{s_name}’)]/…"
assert($browser.element?(xpath))
array=getElement(xpath)
#Assert that the element has been created, check for the name
of the item
getElementName(array,$s_name)
getCreatedbyName(array,$username)

end #createdc

end #class createitem

Arti S. wrote:

TypeError: nil is not a symbol error when runing test.

Has anyone seen this error before?

Post the exact exception report using copy-paste, because it will
include a backtrace, and the first line will give the line number where
the error occurred.

If this is inside a library, look at subsequent lines of the backtrace
until you find a line in your own source. Then indicate which line of
the source code this is.

If I had to guess where the problem is, I would say

      getElementName(array,$s_name)

because you don’t appear to have initialised the global variable $s_name
to anything, and therefore this would be the same as

      getElementName(array,nil)

(@s_name and $s_name are two completely different things)

Brian C. wrote:

If I had to guess where the problem is, I would say

      getElementName(array,$s_name)

because you don’t appear to have initialised the global variable $s_name
to anything, and therefore this would be the same as

      getElementName(array,nil)

(@s_name and $s_name are two completely different things)

You were right, I did not assign a value to the global variable
$username, so I did that and the test ran. Thank you very much.