1

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)
Community
  • 1
  • 1
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
  • Issues like this make me wonder how far the Webdriver people are from Safari support. While I'd never use it personally due to a poor security track record (FF or Chrome would be better) there are hundreds of thousand of users who drink the apple-Koolaide and can't be bothered to change browsers, so as testers, we need to test against it if Mac users are important to us. – Chuck van der Linden Aug 09 '11 at 16:30
  • I do not think webdriver will have support for Safari any time soon. – Željko Filipin Aug 10 '11 at 07:16
  • Anything in particular that makes you think that? is it something the Selenium crowd has against apple, or apple being their usually unhelpful self? or something else? – Chuck van der Linden Aug 15 '11 at 18:08
  • 1
    I think Jari said something like "we are waiting for Apple to step up". :) – Željko Filipin Aug 16 '11 at 07:58
  • great.. ok so they took like 4 years to even start to patch security issues with safari, even after being embarrassed as 'first to fall' at events like PWN2OWN for year after year.. so I guess based on that kind of response time track record, 2014 if we are lucky... great. – Chuck van der Linden Aug 16 '11 at 09:48

1 Answers1

1

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.

Chris Frederick
  • 5,482
  • 3
  • 36
  • 44
jarib
  • 6,028
  • 1
  • 24
  • 27
  • I have done `git submodule update --init` while adding watirspec submodule, and `git submodule update` now does not do anything. I guess watirspec is up to date, right? Should I change something in `.gitmodules`? How to update watirspec? – Željko Filipin Aug 08 '11 at 11:03
  • If you want watirspec master: `cd spec/watirspec && git pull origin master`. watir-webdriver and watir is using the watir2 branch of watirspec, so if you want that, replace 'master' with 'watir2' in the pull command. Then 'cd ../..' and commit the submodule change. – jarib Aug 08 '11 at 11:23
  • tried running `rspec spec` from ruby 1.8.7, but still no luck – Željko Filipin Aug 08 '11 at 11:28
  • thanks, I did not use submodules so far, so I am a bit confused, will try updating – Željko Filipin Aug 08 '11 at 11:31
  • if both watir and watir-webdriver are using watir2 branch, why is it not merged to master? Who is using master then? – Željko Filipin Aug 08 '11 at 11:35
  • Problems again: `git pull origin watir2` says `fatal: Couldn't find remote ref watir2`. – Željko Filipin Aug 08 '11 at 11:44
  • As suggested at https://twitter.com/#!/charley_baker/status/100581801210298368 I have tried to run `spec spec` with rspec 1.3.1 and it works. At least something is moving forward. – Željko Filipin Aug 08 '11 at 15:06
  • `git pull origin watir2` now works fine. Updated to `698e6a3`. – Željko Filipin Aug 09 '11 at 09:54