Bret, thanks! It was indeed a scope issue. And Gavin, point noted
about removing 'include Watir'. Done, thanks.

On Nov 12, 4:46 pm, Bret Pettichord <[EMAIL PROTECTED]> wrote:
> I think the subject line is incorrect. Your problem is that your code to
> initialize the browser needs to be in a startup method. The error
> message you are getting is telling you that @ie is nil (because it has
> not been initialized).
>
> Bret
>
> maven999 wrote:
> > Hi all,
>
> > I am trying to write some code to log into an app via a pop-up window
> > and then click some tabs inside it. However, when I try to encapsulate
> > the login logic into a method, I get an error on console. I am pasting
> > my code below followed by the console error. Any suggestions as to
> > what I'm doing wrong? (I am using wait_until because my text
> > verification fails as page has not loaded yet).
>
> > require 'watir'
> > require 'watir/WindowHelper'
> > require 'watir/testcase'
> > include Watir
>
> > class TC_MTests < Watir::TestCase
>
> > #Variables
> > @url = 'https://1.2.3.4/'
> > @login_title = 'Connect to'
> > @username = 'abc'
> > @password = '123'
>
> > #Start browser
> > @ie = Watir::IE.start(test_site = @url)
>
> > #If prompted about the security certificate, click to bypass
> > certification
> > if @ie.contains_text("Continue to this website (not recommended).")
> >   [EMAIL PROTECTED](:text, 'Continue to this website (not
> > recommended).').click_no_wait
> >     puts "Bypasses the security certificate warning for now."
> > end
>
> >   def test_Login
> > #Use autoit to work with the authentication popup
> > #Pauses execution of the script until the requested window exists
> >     Watir.autoit.WinWait(@login_title)
> >     Watir.autoit.Send(@username)
> >     Watir.autoit.Send('{tab}')
> >     Watir.autoit.Send(@password)
> >     Watir.autoit.Send('{enter}')
> >     puts "Login window pop-up appears and credentials passed."
>
> > #Wait until landing page has loaded completely
> >     wait_until [EMAIL PROTECTED]@username}
>
> > #Check if correct user has logged in
> >     if @ie.contains_text("Logged in as: " [EMAIL PROTECTED])
> >       puts "Test passed. User '" [EMAIL PROTECTED] +"' has logged in."
> >     else
> >       puts "Test failed. Login fails or incorrect user has logged in "
> >     end
> > #End of method
> >   end
> > #End of class
> > end
>
> > ------------------------------------------------------------------------------------------------------------------------------------------------------
> > I get the following error on console:
>
> > P:\>ruby c:\ruby\tests\IanTests_temp.rb
> > Bypasses the security certificate warning for now.
> > Loaded suite c:/ruby/tests/IanTests_temp
> > Started
> > Login window pop-up appears and credentials passed.
> > E
> > Finished in 0.297 seconds.
>
> >   1) Error:
> > test_Login(TC_MTests):
> > NoMethodError: undefined method `text' for nil:NilClass
> >     c:/ruby/tests/IanTests_temp.rb:37:in `test_Login'
> >     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir.rb:110:in
> > `wait_until'
> >     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/waiter.rb:76:in
> > `wait_unt
> > il'
> >     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/waiter.rb:53:in
> > `wait_unt
> > il'
> >     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir/waiter.rb:76:in
> > `wait_unt
> > il'
> >     c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.6/./watir.rb:110:in
> > `wait_until'
> >     c:/ruby/tests/IanTests_temp.rb:37:in `test_Login'
>
> > 1 tests, 0 assertions, 0 failures, 1 errors
> > _______________________________________________________________________________
> > Thanks!
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to watir-general@googlegroups.com
Before posting, please read the following guidelines: 
http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to