You get that error message: NoMethodError: undefined method `text_field' for
nil:NilClass
Because the script can't find the browser, have you defined your browser?*
require 'watir'
require 'watir/testcase'
class TestXXX < Watir::TestCase
     def test_setup
           $b = Watir::IE.start("your url")
     end
     def test_set_value
           $b.text_field(:name, "username").set("user1")
           $b.text_field(:name, "password").set("X")
           $b.link(:id, "button1").fire_event("onMouseDown")
*
*           $b.link(:id, "button1").fire_event("**onMouseUp")*
*     end
     def test_tear_down
           $b.close
     end
end*

Thanks.
Wesley Chen.
For life, the easier, the better.


On Tue, Jan 19, 2010 at 10:23 PM, tester86 <[email protected]> wrote:

> Welsey,
>
> I changed my script according to what you mentioned above. When I run
> it in IE I get the following error message:
>
> NoMethodError: undefined method `text_field' for nil:NilClass
>
> All I am trying to do is to login to an application:
>
> $b.text_field(:name, "username").set("user1")
> $b.text_field(:name, "password").set("X")
> $b.link(:id, "button1").fire_event("onMouseDown")
> $b.link(:id, "button1").fire_event("onMouseUp")
>
>
> Any Idea's since when I run my scripts in IE I seem to get error
> message like that for different things i.e. text field and links
>
> Thanks
> On Jan 15, 8:41 pm, Wesley Chen <[email protected]> wrote:
> > You may change
> > *Class TestGoogle < Test::Unit::TestCase*
> > to
> > *class TestGoogle < Watir::TestCase*
> > And
> > *require 'watir'
> > require 'watir/testcase'*
> >
> > Thanks.
> > Wesley Chen.
> > For life, the easier, the better.
> >
> >
> >
> > On Sat, Jan 16, 2010 at 5:35 AM, Bill Agee <[email protected]> wrote:
> > > Can you post the complete backtrace?  I bet the method "test_entertext"
> is
> > > being run before "test_start".
> >
> > > If I remember correctly, Test::Unit runs the methods inside a test
> class in
> > > asciibetical order.
> >
> > > You might want to collapse all three of those methods into one.
>  There's
> > > probably no real gain in having them be separated.
> >
> > > On Fri, Jan 15, 2010 at 11:31 AM, tester86 <[email protected]>
> wrote:
> >
> > >> Hi
> >
> > >> Please note that this is an example of what tests.
> >
> > >> Class TestGoogle < Test::Unit::TestCase
> >
> > >> def test_start()
> >
> > >> $b=Watir::Browser.start("https://www.google.com";)
> >
> > >> end
> >
> > >> def test_entertext()
> > >> $b.text_field(:name, "SearchField").set("Search")
> > >> $b.button(:name, "btnG").click
> > >> end
> >
> > >> def test_verify()
> >
> > >> if $b.contains_text("Search")
> > >> puts "passed"
> > >> else
> > >> puts "failed"
> > >> end
> >
> > >> end
> >
> > >> end
> >
> > >> In my options.yml if I tell it to run with IE then in command prompt I
> > >> get the error $b is not defined.
> >
> > >> --
> >
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Watir General" group.
> > >> To post to this group, send email to [email protected]
> > >> 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
> >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Watir General" group.
> > > To post to this group, send email to [email protected]
> > > 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- Hide quoted text -
> >
> > - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups
> "Watir General" group.
> To post to this group, send email to [email protected]
> 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
>
-- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To post to this group, send email to [email protected]
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