vendor/gems/gems/firewatir-1.2.1/MozillaBaseElement.rb
#
# Description:
#   Locate all the elements of give tag and type.
#
# Input:
#   tag - tag name of the element for which you want the iterator.
#   types - element type. used in case where same element tag has different types like input has type image, button etc.
#
# Output:
#   Elements array containing all the elements found on the page.
#

Locate all the elements of give tag and type.

tag name of the element for which you want the iterator.
types - element type. used in case where same element tag has different types like input has type image, button etc.

Elements array containing all the elements found on the page.
Locate all the elements of give tag and type . tag name of the element for which you want the iterator . types - element type . used in case where same element tag has different types like input has type image button etc . Elements array containing all the elements found on the page .
def locate_tagged_elements(tag , types = nil)
            jssh_command = "var arr_coll_#{tag}_#{@@current_level}=new Array();"
            @arr_name = "arr_coll_#{tag}_#{@@current_level}"
            if(@container.class == FireWatir::Firefox || @container.class == Frame)
                jssh_command += "var elements_#{tag} = null; elements_#{tag} = #{DOCUMENT_VAR}.getElementsByTagName(\"#{tag}\");"
                if(types != nil and (types.include?("textarea") or types.include?("button")) )
                    jssh_command += "elements_#{tag} = #{DOCUMENT_VAR}.body.getElementsByTagName(\"*\");"
                end
            else
                jssh_command += "var elements_#{@@current_level}_#{tag} = #{@container.element_name}.getElementsByTagName(\"#{tag}\");"
                if(types != nil and (types.include?("textarea") or types.include?("button")) )
                    jssh_command += "elements_#{@@current_level}_#{tag} = #{@container.element_name}.getElementsByTagName(\"*\");"
                end
            end
            if(types != nil)
                jssh_command += "var types = new Array("
                count = 0
                types.each do |type|
                    if count == 0
                        jssh_command += "\"#{type}\""
                        count += 1
                    else
                        jssh_command += ",\"#{type}\""
                    end
                end
                jssh_command += ");"
            else
                jssh_command += "var types = null;"
            end
            if(@container.class == FireWatir::Firefox || @container.class == Frame)
                jssh_command += "for(var i=0; i<elements_#{tag}.length; i++)
                                 {
                                    var element = elements_#{tag}[i];"
            else
                jssh_command += "for(var i=0; i<elements_#{@@current_level}_#{tag}.length; i++)
                                 {
                                    var element = elements_#{@@current_level}_#{tag}[i];"
            end
            jssh_command += "
                                    var same_type = false;
                                    if(types)
                                    {
                                        for(var j=0; j<types.length; j++)
                                        {
                                            if(types[j] == element.type || types[j] == element.tagName)
                                            {
                                                same_type = true;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        same_type = true;
                                    }
                                    if(same_type == true)
                                    {
                                        arr_coll_#{tag}_#{@@current_level}.push(element);
                                    }
                                }
                                arr_coll_#{tag}_#{@@current_level}.length;"
            jssh_command.gsub!(/\n/, "")
            jssh_socket.send("#{jssh_command};\n", 0)
            length = read_socket().to_i;
            elements = Array.new(length)
            for i in 0..length - 1 do
                elements[i] = "arr_coll_#{tag}_#{@@current_level}[#{i}]"
            end
            @@current_level = @@current_level + 1
            return elements
        end
def locate_tagged_elements ( tag , types = nil ) jssh_command = "var arr_coll_#{tag}_#{@@current_level}=new Array();" @arr_name = "arr_coll_#{tag}_#{@@current_level}" if ( @container . class == FireWatir :: Firefox || @container . class == Frame ) jssh_command += "var elements_#{tag} = null; elements_#{tag} = #{DOCUMENT_VAR}.getElementsByTagName(\"#{tag}\");" if ( types != nil and ( types . include? ( "textarea" ) or types . include? ( "button" ) ) ) jssh_command += "elements_#{tag} = #{DOCUMENT_VAR}.body.getElementsByTagName(\"*\");" end else jssh_command += "var elements_#{@@current_level}_#{tag} = #{@container.element_name}.getElementsByTagName(\"#{tag}\");" if ( types != nil and ( types . include? ( "textarea" ) or types . include? ( "button" ) ) ) jssh_command += "elements_#{@@current_level}_#{tag} = #{@container.element_name}.getElementsByTagName(\"*\");" end end if ( types != nil ) jssh_command += "var types = new Array(" count = 0 types . each do | type | if count == 0 jssh_command += "\"#{type}\"" count += 1 else jssh_command += ",\"#{type}\"" end end jssh_command += ");" else jssh_command += "var types = null;" end if ( @container . class == FireWatir :: Firefox || @container . class == Frame ) jssh_command += "for(var i=0; i<elements_#{tag}.length; i++)
                                 {

                                    var element = elements_#{tag}[i];" else jssh_command += "for(var i=0; i<elements_#{@@current_level}_#{tag}.length; i++)
                                 {

                                    var element = elements_#{@@current_level}_#{tag}[i];" end jssh_command += "
                                    var same_type = false;
                                    if(types)
                                    {
                                        for(var j=0; j<types.length; j++)
                                        {
                                            if(types[j] == element.type || types[j] == element.tagName)
                                            {
                                                same_type = true;
                                                break;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        same_type = true;
                                    }
                                    if(same_type == true)
                                    {
                                        arr_coll_#{tag}_#{@@current_level}.push(element);
                                    }
                                }
                                arr_coll_#{tag}_#{@@current_level}.length;" jssh_command . gsub! ( / \n / , "" ) jssh_socket . send ( "#{jssh_command};\n" , 0 ) length = read_socket ( ) . to_i ; elements = Array . new ( length ) for i in 0 .. length - 1 do elements [ i ] = "arr_coll_#{tag}_#{@@current_level}[#{i}]" end @@current_level = @@current_level + 1 return elements end
Description:
Locate all the elements of give tag and type.
Description : Locate all the elements of give tag and type .
# Remove \n that are there in the string as a result of pressing enter while formatting.
 #puts jssh_command
 #puts "elements length is in locate_tagged_elements is : #{length}"

tag
<not_specific>
types
<not_specific>