hi getting error which is not understand able i am new to ruby so please help . i checked all thing which is possible for me.
require 'rubygems'
require 'selenium-webdriver'
require 'test/unit'
class SeleniumTest < Test::Unit::TestCase
driver = Selenium::WebDriver.for :firefox
driver.get "http://localhost:9000/assets/build/index.html#/login"
element = driver.find_element :name => "email"
element.send_keys "[email protected]"
element = driver.find_element :name => "password"
element.send_keys "password"
element.submit
page.find(:xpath, "//a[@href='#/courses/new']").click
#click_link ("//a[@href='#/courses/new']")
puts "Page title is #{driver.title}"
#page.should have_selector(:link_or_button, ' Create New Course...')
wait = Selenium::WebDriver::Wait.new(:timeout => 2000)
driver.quit
end
getting This error:-
TestClass.rb:7:in `<class:SeleniumTest>': undefined local variable or method `logger' for SeleniumTest:Class (NameError)
from TestClass.rb:6:in `<main>'
It seems that you didn't included the complete source code. Besides that, all you code is bare in class
SeleniumTest
. You should put your code into the appropriate method or methods.This type of errors are generated when objects or methods are not created or not scoped well. In your case, the error message is telling you that the object
logger
in line 7 of you script does not exist.As I can see from your source code, line 7 falls into the class definition. I guess you have something like
in that line but you delete it from your post, and in lines 4 and 5 you have something like:
If that is the case, you could put
logger = Logger.new('file.log')
inside the class definition, or define an instance object of typeLogger
inside theSeleniumClass
class, or a global method or something other for logging messages. Examples:or
... or something similar...
I hope this can help you solve your problem. If not, you should put the complete source code and tell us what are you trying to do!