Reputation:
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.
Upvotes: 2
Views: 7248
Reputation: 475
I encountered two issues while getting this running:
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.
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."
This code fixes both problems:
system("open -a /Applications/Firefox.app/Contents/MacOS/firefox-bin http://www.google.com http://www.cpap.com")
Upvotes: 0
Reputation: 24256
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
Upvotes: 0
Reputation: 1239
You can use Watir, as it supports Firefox also: http://wtr.rubyforge.org/platforms.html
Upvotes: 1
Reputation: 1934
You can start any program in ruby with:
`firefox http://www.google.com`
or
system("firefox http://www.google.com")
Upvotes: 4