NameError: undefined local variable or method `null’

I bumped into this error while trying to implement API validation tastcases using Airborne tool :-

undefined local variable or method `null’ for #<RSpec::ExampleGroups::ApiProgramProgramid:0x000000030d2f20>
# ./spec/my_test_name.rb:9:in `block (2 levels) in <top (required)>’

Background of the issue:-

In the ‘expect_json’ part I had given the exact response of my API request as test data for future executions.

So for eg: if this was part of my API response:-


I had given this as part of my Airborne validation script :-


While trying to execute this script, I was continuously encountering this error saying “NameError: undefined local variable or method `null'”. It sure was getting on my nerves as I was’nt able to proceed with my implementation. And we all know how deadlines work! hehe… Anyways…

After a fair bit of trials & failures I found out the issue :-

Ruby as a language stores null values as nil. I was unaware of this as this is the first time I’m working with Ruby & had already started my implementation of Airborne Tool(ruby based), without getting sufficient time to ramp up on the language. We techies are required to deliver fast results you see.. hehe..

So finally, I gave this as my expected json value :-


And voila! The script worked!! 🙂

Hope this helps someone to resolve this specific issue.







Migration from Selenium RC to Webdriver – Executing Javascript APIs

Executing Javascript Doesn’t Return Anything

WebDriver’s JavascriptExecutor will wrap all JS and evaluate it as an anonymous expression. This means that you need to use the “return” keyword:

String title = selenium.getEval("browserbot.getCurrentWindow().document.title");


((JavascriptExecutor) driver).executeScript("return document.title;");