From: khris chank Date: 2012-07-12T17:17:14+09:00 Subject: undefined local variable I use watir in Radrails for testing my app. Iuse 2 classes in my test, where is used variable @ie. Here are their code First class: class Title def initialize(title,url,ie) @title = title @url=url @ie=ie @ie=Watir::IE.attach(:title, @title) rescue Watir::Exception::NoMatchingWindowFoundException puts ("could not find browser") $r.addtoReport(testReport, "check page element", "FAILED", "Page title " + @title +" not found") else @ie=Watir::IE.attach(:url, @url) end end Second class: class Text_pos def initialize(text, object,ie) @text=text @object=object @ie=ie if @ie.contains_text(@text) puts("Test for " + @object + " passed") $r.addtoReport($testReport, "check " + @object, "PASSED", "Test for " + @object + " passed" ) else puts("Test for " + @object + " failed") puts (@ie.link(:text => /Exception:/)) h= @ie.link(:text => /Exception:/) $r.addtoReport($testReport, "check " + @object, "FAILED", h.text) end end end After in test body i executed such commands: Text_pos.new("Glossary Of Terms", "login",ie) Title.new("Company","http://ec2-50-16-62-110.compute-1.amazonaws.com:9100/bobsworld/BPM/Mtebpm000p0001Form.do?resetFilter_action=", ie1) Text_pos.new("Title", "if page is loaded", ie1) But get error - `Test for login passed BPM/try.rb:106:in `
': undefined local variable or method `ie1' for main:Object (NameError)` If i do not use class Title this Text_pos.new("Title", "if page is loaded", ie1) works ok. -- Posted via http://www.ruby-forum.com/.