Issues with link on Watir and Safari?

667 views Asked by At

I am new in using watir but I can only imagine this to be a bug:

require "watir" Watir::Browser.default = 'safari' b = Watir::Browser.new b.goto() => nil b.link(:title, "Start").click

Leads me to the next page as expected but on the following page no link works even they are there

b.link(:title, "Do something").exist? => true

When I then enter

b.link(:title, "Do something").click nothing happens, even the href attribute of course links to the next page (to be more precise, it is the same page but different request parameters)

Identifying the link with :xpath looks similar. The same thing works fine with "firefox" as browser.

I use Safari 5.0.1, ruby 1.8.7 and installed beside others safariwatir-0.3.8


In fact controlling safari partially works but I have no glue why it hangs on the second page. Here is an example using a scenario in the internet:

this works fine:

browser.goto("http://reiseauskunft.bahn.de/bin/query.exe/dn?S=Frankfurt(Main)Hbf&Z=Nrnberg%20Hbf&date=%2B30&time=1500&start=1&") => nil

this also works fine - the link does exist:

browser.link(:title, /Mit Tickets zum Normalpreis/).exist? => true

this does not work - the browser window stays unchanged:

browser.link(:title, /Mit Tickets zum Normalpreis/).click => nil

I would like to try fire_event or fireEvent but irb says invalid method. I guess the hints I found about firing an event are outdated?

1

There are 1 answers

2
Željko Filipin On

As far as I know, the only way to drive Safari is to use safariwatir gem (works only on Mac OS X). Try this (from SafariWatir wiki page at Watir wiki):

require 'rubygems'
require 'safariwatir'
browser = Watir::Safari.new
browser.goto("http://google.com")