TypeError: nil is not a symbol error when running tests

A

Arti Singh

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
 
B

Brian Candler

Arti said:
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)
 
A

Arti Singh

Brian said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top