1

私のシステム構成 Windows 7、IE8 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>
4

2 に答える 2

3

例外に基づいて、古いバージョンの selenium-webdriver と watir-webdriver を使用しています。selenium-webdriver gem と Firefox のバージョンの間に互換性がない可能性があります。

したがって、宝石をアップグレードすることをお勧めします。

gem install selenium-webdriver
gem install watir-webdriver

また、依存関係の 1 つが互換性がない可能性もあります (例: json-pure で例外が発生)。すべてを更新してみることをお勧めします。

gem update
于 2013-10-07T16:31:20.487 に答える
1

gem を更新してみてください。よくわかりませんが、一度試してみてください。

gem update --system
于 2013-10-08T10:03:37.667 に答える