3

I have an array of url strings (i.e. "http://www.cnn.com") which I want to iterate through and open in Safari using watir.

urlArray.each do |url|
browser.goto(url)
end

will open the first page, but it never proceeds to the next pages in the array.

Any ideas on what's going on?

user229044
  • 232,980
  • 40
  • 330
  • 338
YuKagi
  • 2,451
  • 3
  • 21
  • 26
  • Safariwatir is somewhat poorly supported at the moment.. Other than one patch made 5 months ago, there has not been any active development since the fall of 2010. Have you considered maybe using chrome, firefox, or ie? You could run any of those using watir-webdriver, and eventually (we hope, if apple ever steps up) safari once webdriver supports it. – Chuck van der Linden Feb 28 '12 at 19:27
  • Safari support now in Watir-webdriver. See http://watirwebdriver.com/safari/ – Chuck van der Linden Apr 18 '12 at 19:12

1 Answers1

4

This worked for me, it opened both Google and Yahoo.

require "rubygems"
require "safariwatir"

urlArray = ["http://google.com", "http://yahoo.com"]
browser = Watir::Safari.new
urlArray.each do |url|
  browser.goto url
end

When I added "http://www.cnn.com" to urlArray

urlArray = ["http://www.cnn.com", "http://google.com", "http://yahoo.com"]

it opened just cnn.com, so the problem is at that page.

Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
  • Thank you very much. That definitely helps. I'm new to Watir (and Ruby in general really), so I wasn't sure if I was missing something else. – YuKagi May 18 '11 at 18:45