vendor/gems/gems/firewatir-1.2.1/MozillaBaseElement.rb
#
# Description:
#   Traps all the function calls for an element that is not defined and fires them again
#   as it is to the jssh. This can be used in case the element supports properties or methods
#   that are not defined in the corresponding element class or in the base class(Element).
#
# Input:
#   methodId - Id of the method that is called.
#   *args - arguments sent to the methods.
#

Traps all the function calls for an element that is not defined and fires them again
as it is to the jssh. This can be used in case the element supports properties or methods
that are not defined in the corresponding element class or in the base class(Element).

Id of the method that is called.
args - arguments sent to the methods.
Traps all the function calls for an element that is not defined and fires them again as it is to the jssh . This can be used in case the element supports properties or methods that are not defined in the corresponding element class or in the base class ( Element ) . Id of the method that is called . args - arguments sent to the methods .
def method_missing(methId, *args)
            methodName = methId.id2name
            assert_exists
            methodName = "colSpan" if methodName == "colspan"
            if(methodName =~ /invoke/)
                jssh_command = "#{element_object}."
                for i in args do
                    jssh_command += i;
                end
                jssh_socket.send("#{jssh_command};\n", 0)
                return_value = read_socket()
                return return_value
            else
                temp = ""
                assigning_value = false
                if(methodName =~ /(.*)=$/)
                    temp  = "#{element_object}.#{$1}"
                    assigning_value = true
                else
                    temp = "#{element_object}.#{methodName}"
                end
                jssh_socket.send("typeof(#{temp});\n", 0)
                method_type = read_socket()
                if(assigning_value)
                    if(method_type != "boolean" && args[0].class != Fixnum)
                        args[0].gsub!("\\", "\\"*4)
                        args[0].gsub!("\"", "\\\"")
                        args[0].gsub!("\n","\\n")
                        jssh_command = "#{element_object}.#{methodName}\"#{args[0]}\""
                    else
                        jssh_command = "#{element_object}.#{methodName}#{args[0]}"
                    end
                    jssh_socket.send("#{jssh_command};\n", 0)
                    read_socket()
                    return
                end
                methodName = "#{element_object}.#{methodName}"
                if(args.length == 0)
                    if(method_type == "function")
                        jssh_command =  "#{methodName}();\n"
                    else
                        jssh_command =  "#{methodName};\n"
                    end
                else
                    jssh_command =  "#{methodName}("
                    count = 0
                    if args != nil
                        for i in args
                            jssh_command += "," if count != 0
                            if i.kind_of? Numeric
                                jssh_command += i.to_s
                            else
                                jssh_command += "\"#{i.to_s.gsub(/"/,"\\\"")}\""
                            end
                            count = count + 1
                        end
                    end
                    jssh_command += ");\n"
                end
                if(method_type == "boolean")
                    jssh_command = jssh_command.gsub("\"false\"", "false")
                    jssh_command = jssh_command.gsub("\"true\"", "true")
                end
                jssh_socket.send("#{jssh_command}", 0)
                returnValue = read_socket()
                @@current_level = 0
                if(method_type == "boolean")
                    return false if(returnValue == "false")
                    return true if(returnValue == "true")
                elsif(method_type == "number")
                    return returnValue.to_i
                else
                    return returnValue
                end
            end
        end
def method_missing ( methId , * args ) methodName = methId . id2name assert_exists methodName = "colSpan" if methodName == "colspan" if ( methodName =~ / invoke / ) jssh_command = "#{element_object}." for i in args do jssh_command += i ; end jssh_socket . send ( "#{jssh_command};\n" , 0 ) return_value = read_socket ( ) return return_value else temp = "" assigning_value = false if ( methodName =~ / (.*)=$ / ) temp = "#{element_object}.#{$1}" assigning_value = true else temp = "#{element_object}.#{methodName}" end jssh_socket . send ( "typeof(#{temp});\n" , 0 ) method_type = read_socket ( ) if ( assigning_value ) if ( method_type != "boolean" && args [ 0 ] . class != Fixnum ) args [ 0 ] . gsub! ( "\\" , "\\" * 4 ) args [ 0 ] . gsub! ( "\"" , "\\\"" ) args [ 0 ] . gsub! ( "\n" , "\\n" ) jssh_command = "#{element_object}.#{methodName}\"#{args[0]}\"" else jssh_command = "#{element_object}.#{methodName}#{args[0]}" end jssh_socket . send ( "#{jssh_command};\n" , 0 ) read_socket ( ) return end methodName = "#{element_object}.#{methodName}" if ( args . length == 0 ) if ( method_type == "function" ) jssh_command = "#{methodName}();\n" else jssh_command = "#{methodName};\n" end else jssh_command = "#{methodName}(" count = 0 if args != nil for i in args jssh_command += "," if count != 0 if i . kind_of? Numeric jssh_command += i . to_s else jssh_command += "\"#{i.to_s.gsub(/"/,"\\\"")}\"" end count = count + 1 end end jssh_command += ");\n" end if ( method_type == "boolean" ) jssh_command = jssh_command . gsub ( "\"false\"" , "false" ) jssh_command = jssh_command . gsub ( "\"true\"" , "true" ) end jssh_socket . send ( "#{jssh_command}" , 0 ) returnValue = read_socket ( ) @@current_level = 0 if ( method_type == "boolean" ) return false if ( returnValue == "false" ) return true if ( returnValue == "true" ) elsif ( method_type == "number" ) return returnValue . to_i else return returnValue end end end
Description:
Traps all the function calls for an element that is not defined and fires them again
as it is to the jssh.
Description : Traps all the function calls for an element that is not defined and fires them again as it is to the jssh .
#puts "method name is : #{methodName}"
 #assert_enabled
 #puts "#{jssh_command}"
 #puts "return value is : #{return_value}"
 #assert_exists
 #puts "element name is #{element_object}"
 # We get method name with trailing '=' when we try to assign a value to a
 # property. So just remove the '=' to get the type
 #puts "temp is : #{temp}"
 #puts "method_type is : #{method_type}"
 #puts "jssh_command is : #{jssh_command}"
 #puts "In if loop #{methodName}"
 #puts "In else loop : #{methodName}"
 #puts "jssh_command is #{jssh_command}"
 #puts "return value is : #{returnValue}"

methId
<not_specific>
args
<not_specific>