Zeljko,

Possibly this could help, I believe the `getObject( how, what, types, value=nil 
)` method could provide some more infromation to you with regards to this 
matter:

=begin method=

# This is the main method for finding objects on a web page.
        #
        # This method is used internally by Watir and should not be used 
externally. It cannot be marked as private because of the way mixins and 
inheritance work in watir
        #
        #   * how - symbol - the way we look for the object. Supported values 
are
        #                  - :name
        #                  - :id
        #                  - :index
        #                  - :value etc
        #   * what  - string that we are looking for, ex. the name, or id tag 
attribute or index of the object we are looking for.
        #   * types - what object types we will look at. Only used when index 
is specified as the how.
        #   * value - used for objects that have one name, but many values. ex. 
radio lists and checkboxes
        def getObject(how, what, types, value=nil)
            container = getContainerContents # XXX actually this returns a 
collection object (not a container)
            how = :value if how == :caption
            log "getting object - how is #{how} what is #{what} types = 
#{types} value = #{value}"
            
            o = nil
            if how == :index
                index =  what.to_i
                log" getting object #{types.to_s}  at index( #{index}"
                
                objectIndex = 1
                container.each do | thisObject |
                    begin
                        this_type = thisObject.invoke("type")
                    rescue
                        this_type = nil
                    end
                    if types.include?(this_type)
                        if objectIndex == index
                            o = thisObject
                            break
                        end
                        objectIndex += 1
                    end
                end
                return o
                
            else
                container.each do |object|
                    next  unless o == nil
                    
                    begin
                        case how
                        when :id
                            attribute = object.invoke("id")
                        when :name
                            attribute = object.invoke("name")
                        when :value
                            attribute = object.value
                        when :alt
                            attribute = object.alt
                        when :src
                            attribute = object.src
                        when :beforeText
                            attribute = object.getAdjacentText("afterEnd").strip
                        when :afterText
                            attribute = 
object.getAdjacentText("beforeBegin").strip
                        else
                            next
                        end
                        
                        if what.matches(attribute) && 
types.include?(object.invoke("type"))
                            if value
                                log "checking value supplied #{value} ( 
#{value.class}) actual #{object.value} ( #{object.value.class})"
                                if object.value.to_s == value.to_s
                                    o = object
                                end
                            else # no value
                                o = object
                            end
                        end
                        
                    rescue => e
                        log 'IE#getObject error ' + e.to_s 
                    end
                    
                end
            end
            
            return o
        end

=end method=

It is unclear to me why for this: "({:name => 'foo', :index => 2})" as your 
parameters list that you placed these parameters inside a block " { } ".

Maybe more will chime in to get your question answered :)
Nathan Christie
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=6479&messageID=18413#18413
_______________________________________________
Wtr-general mailing list
Wtr-general@rubyforge.org
http://rubyforge.org/mailman/listinfo/wtr-general

Reply via email to