1
我剛開始on Rails的3開始使用Ruby使用Selenium,我有我的代碼硒RC錯誤未知協議:本地主機
before(:all) do
@verification_errors = []
@selenium_driver = Selenium::Client::Driver.new \
:host => "localhost",
:port => 2195,
:browser => "*firefox C:/Program Files (x86)/Mozilla Firefox/firefox.exe",
:url => "localhost:3000",
:timeout_in_second => 60
@selenium_driver.start_new_browser_session
end
after(:all) do
@selenium_driver.close_current_browser_session
@verification_errors.should == []
end
it "should open the create new user page" do
page.open "http://localhost:3000/"
!page.is_text_present("translation missing").should be_false
page.click "link=Register"
page.wait_for_page_to_load "30000"
!page.is_text_present("translation missing").should be_false
page.is_text_present("New Account").should be_true
end
但是,當我試圖運行它們,我
11:02:29.118 INFO - Command request: getNewBrowserSession[*firefox C:/Program Files (x86)/Mozilla Firefox/firefox.exe, localhost:3000, , ] on session null
11:02:29.118 INFO - creating new remote session
11:02:29.119 INFO - Allocated session 5cbd2c60271b490ea90eccb193cb1d84 for localhost:3000, launching...
11:02:29.119 ERROR - Failed to start new browser session, shutdown browser and clear all session data
java.lang.RuntimeException: java.net.MalformedURLException: unknown protocol: localhost
at org.openqa.selenium.net.Urls.toProtocolHostAndPort(Urls.java:32)
at org.openqa.selenium.browserlaunchers.LauncherUtils.getDefaultRemoteSessionUrl(LauncherUtils.java:121)
at org.openqa.selenium.server.browserlaunchers.FirefoxChromeLauncher.launchRemoteSession(FirefoxChromeLauncher.java:413)
at org.openqa.selenium.server.browserlaunchers.FirefoxLauncher.launchRemoteSession(FirefoxLauncher.java:110)
at org.openqa.selenium.server.BrowserSessionFactory.createNewRemoteSession(BrowserSessionFactory.java:373)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:125)
at org.openqa.selenium.server.BrowserSessionFactory.getNewBrowserSession(BrowserSessionFactory.java:87)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.getNewBrowserSession(SeleniumDriverResourceHandler.java:786)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.doCommand(SeleniumDriverResourceHandler.java:423)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handleCommandRequest(SeleniumDriverResourceHandler.java:394)
at org.openqa.selenium.server.SeleniumDriverResourceHandler.handle(SeleniumDriverResourceHandler.java:147)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1530)
at org.openqa.jetty.http.HttpContext.handle(HttpContext.java:1482)
at org.openqa.jetty.http.HttpServer.service(HttpServer.java:909)
at org.openqa.jetty.http.HttpConnection.service(HttpConnection.java:820)
at org.openqa.jetty.http.HttpConnection.handleNext(HttpConnection.java:986)
at org.openqa.jetty.http.HttpConnection.handle(HttpConnection.java:837)
at org.openqa.jetty.http.SocketListener.handleConnection(SocketListener.java:243)
at org.openqa.jetty.util.ThreadedServer.handle(ThreadedServer.java:357)
at org.openqa.jetty.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
Caused by: java.net.MalformedURLException: unknown protocol: localhost
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at org.openqa.selenium.net.Urls.toProtocolHostAndPort(Urls.java:24)
... 19 more
11:02:29.121 INFO - Got result: Failed to start new browser session: Error while launching browser on session null
我不明白localhost如何成爲一個未知的協議,並且我沒有通過我自己的搜索找到很多幫助。
有人可以幫我,在此先感謝
非常感謝你 – Souloikj 2011-03-17 17:25:48
那麼,它工作? – Argote 2011-03-17 17:40:57
完美的作品,再次感謝 – Souloikj 2011-03-17 19:23:04