This isn't the best way to do some of this stuff (I've since found better ways, but haven't updated the code):

# Open the file in the browser.
        # Mac OS
if(@os == MACOS) #assuming Firefox for now--Fortius has problems with Safari
          `open "#{suite}#{url_suffix}"` if(@browser == SAFARI)

fork {`/Applications/Firefox.app/Contents/MacOS/firefox- bin "#{suite}#{url_suffix}"`} if(@browser == FIREFOX)
        end

        # Linux
        if(@os == LINUX)
          if(@browser == FIREFOX)
          end
        end

        # Windows
        if(@os == WINDOWS)
          `start #{suite}#{windows_url_suffix}` if(@browser == IE)

`start firefox.exe #{suite}#{windows_url_suffix}` if (@browser == FIREFOX)
        end

        # Join the thread, then quit the browser
        processor_thread.join

        # Quit the browser
        puts @os, @browser
        if(@os == MACOS) #assuming Firefox for now
          if(@browser == FIREFOX)
            line = `ps -A | grep "Firefox.app"`
            process = line.split
            puts "Killing [EMAIL PROTECTED], process # #{process[0]}"
            `kill -9 #{process[0]}`
          elsif(@browser == SAFARI)
            line = `ps -A | grep "Safari.app"`
            process = line.split
            puts "Killing [EMAIL PROTECTED], process # #{process[0]}"
            `kill #{process[0]}`
          end
        end

        if(@os == WINDOWS)
          `TASKKILL /F /IM iexplore.exe /T` if(@browser == IE)

          `TASKKILL /F /IM firefox.exe /T` if(@browser == FIREFOX)
        end
      end


I've actually written an app around webrick using threads that
a) launches webrick,
b) launches the browser of choice and the desired suite of tests,
c) waits for the test results (there's a timeout as well),
d) writes the test results to an html file,
e) kills the browser,
f) starts over from b until all suites have been run
g) kills webrick

I've been meaning to take the time to polish this up and share it back with the group. I'll try to make time sometime in the next few weeks to do so.

Jamie


On Oct 12, 2005, at 11:28 AM, Luke Closs wrote:

Hey,

Does anyone have any code that starts/stops browsers?

I'd like to automate selenium testing by having a process start
firefox (say), tell it to go to
http://test-server/selenium/?auto=true, and then kill the browser when
it's done.

I'm interested in any code/tips to help doing this for firefox, opera,
safari, and IE.

Cheers,
Luke

--
Luke Closs
PureMessage Developer
There is always time to juggle in the Sophos Zone.
_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users


_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users

Reply via email to