我正在按照safariwatir自述文件中的 watirspec指令运行 safariwatir 。
$ git clone git://github.com/redsquirrel/safariwatir.git
Cloning into safariwatir...
...
$ cd safariwatir
$ git submodule update --init
Submodule 'spec/watirspec' (git://github.com/jarib/watirspec.git) registered for path 'spec/watirspec'
Cloning into spec/watirspec...
...
Submodule path 'spec/watirspec': checked out '4e080506694b079d08135e610716e5655f07183f'
由于我有 rspec 2,我已替换spec spec
为rspec spec
:
$ rspec spec
/Users/zeljko/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': /Users/zeljko/Documents/projekt/safariwatir/spec/watirspec/lib/server.rb:91: invalid multibyte char (US-ASCII) (SyntaxError)
...
正如jarib在他的回答中所说,safariwatir 的 watirspec 指向旧提交( 2009 年的4e08),所以我已经更新它以指向 watirspec 的 watir2 分支中的最新提交。
$ cd spec/watirspec && git pull origin watir2
From git://github.com/jarib/watirspec
* branch watir2 -> FETCH_HEAD
Updating 4e08050..fa27ccf
...
safariwatir 的 watirspec 现在指向 fa27ccf,但rspec spec
现在抱怨找不到spec/implementation.rb
文件。
$ rspec spec
/Users/zeljko/Documents/projekt/safariwatir/spec/watirspec/lib/runner.rb:58:in `load': no such file to load -- /Users/zeljko/Documents/projekt/safariwatir/spec/implementation.rb (LoadError)
我spec/implementation.rb
根据 watirspec 自述文件中的说明并通过阅读watir、watir-webdriver和celerity implementation.rb
文件创建了文件。
$LOAD_PATH.unshift("../lib")
require "safariwatir"
include Watir::Exception
WatirSpec.implementation do |imp|
imp.name = :safariwatir
imp.browser_class = Watir::Safari
end
最后它起作用了:
$ rspec spec
...
Finished in 27.89 seconds
1005 examples, 997 failures
99% 的失败是这样的:
10) Browser#html returns the DOM of the page as an HTML string
Failure/Error: browser.goto(WatirSpec.files + "/right_click.html")
Appscript::CommandError:
CommandError
OSERROR: -609
MESSAGE: Connection is invalid.
COMMAND: app("/Applications/Safari.app").documents[1].URL.set("file:///Users/zeljko/Documents/projekt/safariwatir/spec/watirspec/html/right_click.html")
# ./lib/safariwatir/scripter.rb:253:in `block in navigate_to'
# ./lib/safariwatir/scripter.rb:697:in `page_load'
# ./lib/safariwatir/scripter.rb:252:in `navigate_to'
# ./lib/safariwatir.rb:960:in `goto'
# ./spec/watirspec/browser_spec.rb:23:in `block (4 levels) in <top (required)>'
环境:
Mac OS X 10.6.8,Safari 5.1。
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
$ gem list
*** LOCAL GEMS ***
...
rspec (2.6.0)
...
rubygems-update (1.8.7)
...
safariwatir (0.4.0)