I am following Running safariwatir against watirspec instructions from safariwatir readme.
$ 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'
Since I have rspec 2, I have replaced spec spec
with 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)
...
As jarib said in his answer, safariwatir's watirspec points to and old commit (4e08 from 2009), so I have updated it to point to the latest commit in watir2 branch of watirspec.
$ cd spec/watirspec && git pull origin watir2
From git://github.com/jarib/watirspec
* branch watir2 -> FETCH_HEAD
Updating 4e08050..fa27ccf
...
safariwatir's watirspec now points to fa27ccf, but rspec spec
now complains that it could not find spec/implementation.rb
file.
$ 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)
I have created spec/implementation.rb
file according to instructions from watirspec readme and by reading watir, watir-webdriver and celerity implementation.rb
file.
$LOAD_PATH.unshift("../lib")
require "safariwatir"
include Watir::Exception
WatirSpec.implementation do |imp|
imp.name = :safariwatir
imp.browser_class = Watir::Safari
end
Finally it works:
$ rspec spec
...
Finished in 27.89 seconds
1005 examples, 997 failures
99% of failures look like this:
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)>'
Environment:
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)
You should be running rspec spec
(the spec binary seems to point to your non-RVM Ruby install in /Library/...).
The encoding issue was fixed here - so safariwatir's watirspec submodule is quite outdated. Either update the submodule, or use 1.8.7 to avoid the problem.