2013-10-07 75 views
1

我的系統配置Windows 7,IE8 當我嘗試打開Firefox瀏覽器時出現以下錯誤任何人都可以幫助我如何解決這些問題。無法在watir中使用cmd提示符打開Firefox瀏覽器

C:\Users\khan>irb 

irb(main):001:0> require 'rubygems' 
=> true 

irb(main):002:0> require 'watir-webdriver' 
=> true 

irb(main):003:0> e=Watir::Browser.new :firefox 
NoMethodError: undefined method `ascii_only?' for {}:Hash 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/json_pure-1.4.3/lib/json/pure/generator.rb:393:in `to_json' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/multi_json-1.3.7/lib/multi_json/adapters/json_common.rb:11:in `dump' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/multi_json-1.3.7/lib/multi_json.rb:115:in `dump' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/json_helper.rb:23:in `json_dump' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:254:in `write_prefs' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:253:in `each' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:253:in `write_prefs' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:252:in `open' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:252:in `write_prefs' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:232:in `update_user_prefs_in' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/profile.rb:79:in `layout_on_disk' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:58:in `create_profile' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:34:in `launch' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/socket_lock.rb:20:in `locked' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/launcher.rb:32:in `launch' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/firefox/bridge.rb:20:in `initialize' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `new' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver/common/driver.rb:31:in `for' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/selenium-webdriver-2.29.0/lib/selenium/webdriver.rb:67:in `for' 
    from D:/Ruby_1.8.7/lib/ruby/gems/1.8/gems/watir-webdriver-0.6.2/lib/watir-webdriver/browser.rb:46:in `initialize' 
    from (irb):3:in `new' 
    from (irb):3 
    from ♥:0irb(main):004:0> 
+0

喜的朋友,當我嘗試需要的Watir-webdriver的我遇到了以下錯誤 – khan

+0

後打開火狐瀏覽器是問題的Firefox特定或者你得到同樣的異常在其他瀏覽器(如Chrome和IE) ? –

+0

yaa該問題與其他瀏覽器太....鉻,其罰款與IE – khan

回答

3

根據例外情況,您使用的是舊版本的selenium-webdriver和watir-webdriver。 selenium-webdriver gem和Firefox版本之間可能存在不兼容性。

因此,我建議升級寶石:

gem install selenium-webdriver 
gem install watir-webdriver 

這也可能是可能的依賴關係之一,也是不相容的(如JSON-純在異常發生時)。您可能想嘗試更新所有內容。

gem update 
+0

仍然是相同的問題得到相同的錯誤 – khan

+0

是啊它不工作,因爲在鉻我能夠打開瀏覽器,但是當我說像「suchoto」www.gmail.com'「它不導航對於Firefox而言,它根本不工作 – khan

1

您應該嘗試更新寶石,我不確定它,但嘗試一次。

gem update --system 
+0

當我說寶石更新 - 系統我得到以下錯誤C:\ Users \ shaik>寶石更新 - 系統 更新rubygems-update 錯誤:執行寶石時.. 。(Gem :: GemNotFoundException) 在本地或版本庫中找不到有效的gem'rubygems-update'(2.1.5) – khan

+0

它甚至不能用於寶石更新 - 系統可以解決它的任何其他答案 – khan

相關問題