Thank you.  Though it worked only if I supply the values for the arguements 
in the method as well. So to give an example, I am pasting the code with 
the incorrect credentials you provided. (I have used correct login 
credentials).
I have also taken Zeljko suggestion to start method name with lower case. 
 
require 'watir' 
require 'rubygems' 
$browser = Watir::IE.new 
class Login 
        def loginbyuname(uname,pwd) 
                $browser.goto("http://mail.yahoo.com";) 
                puts "Correct URL" 
                $browser.text_field(:id, "username").set('per...@yahoo.com') 

                $browser.text_field(:id, "passwd").set('abcd1234') 
                $browser.button(:id, ".save").click 
        end 
         
end 
uname = "per...@yahoo.com" 
pwd = "abcd1234" 
lgn = Login.new() 
lgn.loginbyuname(uname,pwd) 
 
**********
On Sunday, September 30, 2012 5:40:56 PM UTC-7, Joe Fl wrote: 
>
> Hi, 
>
> I tested this but with incorrect credential but this works.  Hope this 
> helps. 
>
> require 'watir' 
> require 'rubygems' 
> $browser = Watir::IE.new 
>
> class Login 
>
>         def LoginByUname(uname,pwd) 
>                 $browser.goto("http://mail.yahoo.com";) 
>                 puts "Correct URL" 
>                 $browser.text_field(:id, "username").set('uname') 
>                 $browser.text_field(:id, "passwd").set('pwd') 
>                 $browser.button(:id, ".save").click 
>         end 
>          
> end 
>
> uname = "per...@yahoo.com <javascript:>" 
> pwd = "abcd1234" 
>
> lgn = Login.new() 
> lgn.LoginByUname(uname,pwd) 
>
> Joe 
>
> On Sun, Sep 30, 2012 at 6:54 PM, newlearner <rubyl...@gmail.com<javascript:>> 
> wrote: 
> > Hi Joe, thanks for the reply. 
> > 
> > Yes it still failed and the error was 
> > Undefined local variable or method 'browser' for Login:Class (NameError) 
> > 
> > On Sunday, September 30, 2012 2:51:47 PM UTC-7, Joe Fl wrote: 
> >> 
> >> Hi. 
> >> 
> >> I would drop the $browser and just call the method.  Though the method 
> my 
> >> fail because the self isn't initialized as the $browser. 
> >> 
> >> On Sep 30, 2012 5:44 PM, "newlearner" <rubyl...@gmail.com> wrote: 
> >>> 
> >>> 
> >>> Here is the code and the  the error I am getting: 
> >>> 
> >>> undefined method "LoginByUname" for #<Watir::IE:0x53c756c> 
> >>> <NoMethodError> 
> >>> 
> >>> require 'watir' 
> >>> require 'rubygems' 
> >>> $browser = Watir::IE.new 
> >>> 
> >>> class Login 
> >>> $browser.goto("http://mail.yahoo.com";) 
> >>> puts "Correct URL" 
> >>> 
> >>> def LoginByUname(uname,pwd) 
> >>> self.text_field(:id, "username").set('uname') 
> >>> self.text_field(:id, "passwd").set('pwd') 
> >>> self.button(:id, ".save").click 
> >>> end 
> >>> 
> >>> $browser.LoginByUname(@uname,@pwd) 
> >>> end 
> >>> 
> >>> 
> >>> 
> >>> On Friday, September 28, 2012 1:12:45 PM UTC-7, Joe Fl wrote: 
> >>>> 
> >>>> Hi, 
> >>>> 
> >>>> Can you paste your code in here? 
> >>>> 
> >>>> Thank you, 
> >>>> Joe 
> >>>> 
> >>>> On Fri, Sep 28, 2012 at 3:49 PM, newlearner <rubyl...@gmail.com> 
> wrote: 
> >>>> > Hi there, 
> >>>> > I am getting this error when I ran the script in ruby. Any help is 
> >>>> > appreciated. 
> >>>> > 
> >>>> > undefined method "LoginByAccountno" for #<Watir::IE:0x68441e8> 
> >>>> > 
> >>>> > thanks. 
> >>>> > 
> >>>> > -- 
> >>>> > Before posting, please read http://watir.com/support. In short: 
> search 
> >>>> > before you ask, be nice. 
> >>>> > 
> >>>> > watir-...@googlegroups.com 
> >>>> > http://groups.google.com/group/watir-general 
> >>>> > watir-genera...@googlegroups.com 
> >>> 
> >>> -- 
> >>> Before posting, please read http://watir.com/support. In short: 
> search 
> >>> before you ask, be nice. 
> >>> 
> >>> watir-...@googlegroups.com 
> >>> http://groups.google.com/group/watir-general 
> >>> watir-genera...@googlegroups.com 
> > 
> > -- 
> > Before posting, please read http://watir.com/support. In short: search 
> > before you ask, be nice. 
> > 
> > watir-...@googlegroups.com <javascript:> 
> > http://groups.google.com/group/watir-general 
> > watir-genera...@googlegroups.com <javascript:> 
>

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

watir-general@googlegroups.com
http://groups.google.com/group/watir-general
watir-general+unsubscr...@googlegroups.com

Reply via email to