This sounds like more a fundamental Ruby issue than anything.  I'm not
sure how your first assert statement would work since you're calling a
local 'browser' variable within your method.

Try this out:

######################
require 'watir'
require 'watir/testcase'

class VerifyTest < Watir::TestCase

  def url()
    @browser = Watir::Browser.new
    @browser.goto "http://www.google.com";
  end

  def test01
    # start the method
    url()

    # verify the element
    verify(@browser.text_field(:name, "q").exists?, message="Field not
active.")
  end
end

######################

This should pass just fine.  If you're interested in a cool free
online Ruby course, I would suggest:

http://rubylearning.org/

I'm currently taking this course, and it has helped me tremendously!
Hope this helps...

-George



On Aug 5, 2:51 am, Yuvraj <yuvrajjagad...@gmail.com> wrote:
> Hi,
>
> I have installed the ruby 1.8.6 and WATIR 1.6.2.
>
> I am checking whether a link is active or not with the following
> verify statement.
>
> verify((browser.link(:text, "1").exists?), message="Link not active.")
>
> The above statement works fine.
>
> But when I use the above statement with global variable as shown below
> it does not work and  pass everytime whether the link is active or
> not.
>
> verify((@browser.link(:text, "1").exists?), message="Link not
> active.")
>
> In the above case I am getting the @browser from common file as shown
> below.
>
> # Calling function url to open specific site browser
>   @browser = url()
>
> And common file has following code.
> # This function open the browser and navigate to site
> def url()
>   browser = Watir::Browser.new
>   browser.goto "http://www.acs.org";
>   return browser
> end
>
> Is there any other way through which I can check the same thing?
>
> Thanks & Regards
> Yuvraj
--~--~---------~--~----~------------~-------~--~----~
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 
watir-general-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/watir-general
-~----------~----~----~----~------~----~------~--~---

Reply via email to