tanamonの稀に良く書く日記

KEEP CALM AND DRINK BEER

SeleniumRCでFirefoxを起動する場合にはパスを通す

SeleniumRCでは何も設定しなくてもIE/Safari/Chromeは普通に起動するけど、Firefoxだけはそのままでは起動できない。起動させるにはfirefox.exeがある場所を環境変数としてパスを通すか、ブラウザ指定(*firefox等)の後ろにfirefox.exeの位置を指定する必要がある。


どっちで設定してもいいんだけど、環境設定で指定するとFirefox2とFirefox3の両方でテストしたい場合等で切り替えができないので、直接指定してやる方法のほうが柔軟性があると思う。


設定のしかたはブラウザ指定の後にスペースを空けてfirefox.exeへのフルパスを書くだけ。

 "*firefox C:\\Program Files\\Mozilla Firefox 3\\firefox.exe"

パスにスペースがある場合でも""等では囲まずに書くという衝撃仕様ですけど、これで動きます。

firefox.exeが見つからない時に出るエラー

17:43:47.031 WARN - POST /selenium-server/driver/ HTTP/1.1
java.lang.RuntimeException: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:

 *firefox3c:\blah\firefox.exe
	at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(BrowserLauncherFactory.java:145)
	at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.getBrowserLauncher(BrowserLauncherFactory.java:85)
	at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:341)
	at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:119)
	at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:82)
	at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:658)
	at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:392)
	at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:368)
	at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:129)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
	at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
	at org.mortbay.http.HttpServer.service(HttpServer.java:909)
	at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
	at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
	at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
	at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
	at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
	at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment
variable, or explicitly specify a path to Firefox 3 like this:

 *firefox3c:\blah\firefox.exe
	at org.openqa.selenium.server.browserlaunchers.locators.Firefox2or3Locator.findBrowserLocationOrFail(Firefox2or3Locator.java:27)
	at org.openqa.selenium.server.browserlaunchers.BrowserInstallationCache.locateBrowserInstallation(BrowserInstallationCache.java:26)
	at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.(FirefoxLauncher.java:30)
	at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.(FirefoxLauncher.java:26)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
	at org.openqa.selenium.server.browserlaunchers.BrowserLauncherFactory.createBrowserLauncher(BrowserLauncherFactory.java:134)
	... 17 more