How is it possible to open FireFox browser by Ruby(for automation script)? I use @browser = RSpecSeleniumHelper.connect_browser('/admin/', '*firefox'), but it doesn't work.
You can start any program in ruby with:
`firefox http://www.google.com` or system("firefox http://www.google.com")
You can use Watir, as it supports Firefox also: http://wtr.rubyforge.org/platforms.html
You may have to check if the Selenium Remote Control is start or not, normally it is running at port 4444.
java -jar selenium-server-xxx.jar
then you can use
@browser = Selenium::Client::Driver.new( :host => "localhost", :port => 4444, :browser => "*firefox", #*iexplore, *firefox3, *safari... :url => "http://www.google.com/", :timeout_in_second => 60) @browser.start_new_browser_session
Hope this helps, you can find more demo by download Selenium RC
I encountered two issues while getting this running:<ol> <li>
If you are running your Ruby app from MacOS, the command firefox may not be properly aliased by default and so may fail without errors printed to your Ruby console.</li> <li>
If you already have an instance of Firefox open, you will get a message saying "Close Firefox - A copy of Firefox is already open. Only one copy of Firefox can be open at a time."</li> </ol>
This code fixes both problems:
system("open -a /Applications/Firefox.app/Contents/MacOS/firefox-bin http://www.google.com http://www.cpap.com")<ol> <li>open's -a option Opens with the specified application.</li> <li>The file path list works for me. If it won't load for you, first drop it and try plain "firefox" and failing that try "/Applications/Firefox.app/Contents/MacOS/firefox"</li> <li>The example above shows two URLs separated by a space. You can use just one URL or as many as you care to following this pattern.</li> </ol>