vendor/gems/gems/firewatir-1.2.1/firewatir.rb
#
# Description:
#   Finds a Firefox browser window with a given title or url.
#

Finds a Firefox browser window with a given title or url.
Finds a Firefox browser window with a given title or url .
def find_window(how, what)
            jssh_command = "getWindows().length;";
            $jssh_socket.send("#{jssh_command}\n", 0)
            @@total_windows = read_socket()
            jssh_command =  "var windows = getWindows(); var window_number = 0;var found = false;
                             for(var i = 0; i < windows.length; i++)
                             {
                                var attribute = '';
                                if(\"#{how}\" == \"url\")
                                {
                                    attribute = windows[i].getBrowser().contentDocument.URL;
                                }
                                if(\"#{how}\" == \"title\")
                                {
                                    attribute = windows[i].getBrowser().contentDocument.title;
                                }"
            if(what.class == Regexp)                    
                oldRegExp = what.to_s
                newRegExp = "/" + what.source + "/"
                flags = oldRegExp.slice(2, oldRegExp.index(':') - 2)
                for i in 0..flags.length do
                    flag = flags[i, 1]
                    if(flag == '-')
                        break;
                    else
                        newRegExp << flag
                    end
                end
                jssh_command += "var regExp = new RegExp(#{newRegExp});
                                 found = regExp.test(attribute);"
            else
                jssh_command += "found = (attribute == \"#{what}\");"
            end
            jssh_command +=     "if(found)
                                {
                                    window_number = i;
                                    break;
                                }
                            }
                            window_number;"
            jssh_command.gsub!(/\n/, "")
            $jssh_socket.send("#{jssh_command}\n", 0)
            window_number = read_socket()
            return window_number.to_i
        end
def find_window ( how , what ) jssh_command = "getWindows().length;" ; $jssh_socket . send ( "#{jssh_command}\n" , 0 ) @@total_windows = read_socket ( ) jssh_command = "var windows = getWindows(); var window_number = 0;var found = false;
                             for(var i = 0; i < windows.length; i++)
                             {
                                var attribute = '';
                                if(\"#{how}\" == \"url\")
                                {
                                    attribute = windows[i].getBrowser().contentDocument.URL;
                                }
                                if(\"#{how}\" == \"title\")
                                {
                                    attribute = windows[i].getBrowser().contentDocument.title;
                                }" if ( what . class == Regexp ) oldRegExp = what . to_s newRegExp = "/" + what . source + "/" flags = oldRegExp . slice ( 2 , oldRegExp . index ( ':' ) - 2 ) for i in 0 .. flags . length do flag = flags [ i , 1 ] if ( flag == '-' ) break ; else newRegExp << flag end end jssh_command += "var regExp = new RegExp(#{newRegExp});
                                 found = regExp.test(attribute);" else jssh_command += "found = (attribute == \"#{what}\");" end jssh_command += "if(found)
                                {
                                    window_number = i;
                                    break;
                                }
                            }
                            window_number;" jssh_command . gsub! ( / \n / , "" ) $jssh_socket . send ( "#{jssh_command}\n" , 0 ) window_number = read_socket ( ) return window_number . to_i end
Description:
Finds a Firefox browser window with a given title or url.
Description : Finds a Firefox browser window with a given title or url .
#puts "total windows are : " + @@total_windows.to_s
 # Construct the regular expression because we can't use it directly by converting it to string.
 # If reg ex is /Google/i then its string conversion will be (?i-mx:Google) so we can't use it.
 # Construct the regular expression again from the string conversion.
 #puts "jssh_command is : #{jssh_command}"
 #puts "window number is : " + window_number.to_s

how
<not_specific>
what
<not_specific>