views:

72

answers:

2

Hi there,

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

A: 

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")
Željko Filipin
Thanx for your feedback. I tried the additional 'safariwatir' require but no change. I precised my answer below
Thorsten
Please post your script in the whole. I do not understand what is the problem. Also, do not require watir, just safariwatir.
Željko Filipin
A: 

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?

Thorsten
Please edit your original question (and delete this answer), do not post additional data as an answer. My guess is that fire_event method in not implemented in safariwatir.
Željko Filipin