This initially confused me as well. I believe Ram’s root question is:

 

  • How can I easily use both Watir and Watir_simple methods side by side.

 

Because Watir::Simple expects that you get/initialized the IE handle from it, you can’t use its methods without initializing/cheating by init’ing its browser instance.

 

This seems to be a common question to me…folks look in the API doc, and notice how easy the Simple methods are. They start with a non-simple example and thing the API docs are a library of “statics” they can call anytime. Then they start calling Simple methods.

 

Why not add a method to Simple to “set” its browser instance or come up with some way these APIs can be more interchangeable?

 

Scott

 


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ramanjaneya
Sent: Saturday, July 09, 2005 2:20 AM
To: [email protected]
Subject: [Wtr-general] How to use methods of different modules in a single.rb file

 

Hi:

 

We just started using Watir tool to automate one of WebApplications. While we start using Watir too, we got few doubts which are described below. Would be great help for us if you can clarify our doubts mentioned below.

 

1. In Watir API reference guide, what is the Top layer class(I mean Watir::FactoryMethods or Watir.IE or Watir:Simple or anyother)?

 

2. Please see the below code: 

 

    ========================================

    require 'watir'
    include Watir

 

    a = Watir::IE.new

   

    a.text_field(:name,  "user_name").set("admin")
    a.text_field(:name,  "user_password").set("admin")

    ========================================

 

    (a). In the above code, after last line of code, if I want use the "assert_text_in_field()"  which is in module "Watir::Simple", what should I need to do?

 

          What I did for the above is:(but not succeeded)

          Included the two lines of following code at the start:

 

        ========================================

        require 'watir'
        include Watir

       

        require 'Watir_simple.rb'

        include Simple

 

 

        a = Watir::IE.new

        a.goto("http://172.16.6.74/sample/index.php")

   

        a.text_field(:name,  "user_name").set("admin")
        a.text_field(:name,  "user_password").set("admin")

 

        a.assert_text_in_filed("user_name", "Ramanjaneya")

        ===========================================

 

        But the above code is not working. It is throwing error message:  Undefined method assert_text_in_filed.             

 

    (b). The above (a) doubt is specific. In general speaking if we want to use different methods of different modules how we need to proceed?   

 

3. Watir guide thats provided in website is not that much helpful in providing examples. Would be great if you can provide some real time examples' code so that

    we can walk through the code to understand how to use the watir tool. or atleast

    would be great help for atleast if you can tell me where i can find.

 

Thanks a lot in advance for your valuable time in helping us out.

 

Thanks & Regards,

Ramanjaneya Reddy.

 

 

_______________________________________________
Wtr-general mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to