我一直在苦苦挣扎,试图让一个简单的selenium-webdriver ruby测试脚本正确执行。
我真的很感激,如果有人能够解释我如何调试这个问题,或者有人之前已经解决了这个问题,那就解决它了。
我的环境设置如下:
运行ruby版本的Mac OS X:ruby-2.0.0-p247
安装宝石:
执行的脚本:
#!/usr/bin/env ruby
require "selenium-webdriver"
driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://google.com"
element = driver.find_element(:name, 'q')
element.send_keys "Hello WebDriver!"
element.submit
puts driver.title
driver.quit
这是我执行脚本时遇到的错误:
/.rvm / rubies / ruby-2.0.0-p247 / lib / ruby / 2.0.0 / json / common.rb:155:在`parse'中:未初始化的常量JSON :: Parser(NameError)
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / multi_json-1.7.8 / lib / multi_json / adapters / json_common.rb:16:in"load'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / multi_json-1.7.8 / lib / multi_json / adapter.rb:19:in"load'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / multi_json-1.7.8 / lib / multi_json.rb:118:in"load'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / common / json_helper.rb:11:in`json_load'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / profile.rb:30:in`default_preferences'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / profile.rb:221:in`update_user_prefs_in'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / profile.rb:79:in“layout_on_disk”
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / launcher.rb:58:in,create_profile'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / launcher.rb:34:in block in launch'< / p>
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / socket_lock.rb:20:in`locked'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / launcher.rb:32:in“launch”
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / firefox / bridge.rb:24:in`initialize'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / common / driver.rb:31:in"new'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver / common / driver.rb:31:in`for'
来自〜/ .rvm / gems / ruby-2.0.0-p247 / gems / selenium-webdriver-2.33.0 / lib / selenium / webdriver.rb:67:in`for'