1

I've been pulling my hair out trying to figure out why Safari isn't getting cell text from a table.

It seems like this should be working

require 'rubygems'
require 'safariwatir'
@b = Watir::Safari.new
@b.goto(my_webpage)
cell = @b.table(:class, "user-table")[0][1] #getting row 0 cell 1 
puts cell.text 

I get the error

/Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir/scripter.rb:189:in `find_cell': uninitialized constant Watir::JavaScripter::MissingWayOfFindingObjectException (NameError)

Chrome works just find.

Totally confused!

Thanks for your help.

Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
Brad Askins
  • 53
  • 1
  • 1
  • 6

1 Answers1

0

If you use Watir-Webdriver gem to drive Chrome and Safari it should take care of your problem.

Safariwatir and Watir-Webdriver have similar a API, but not completely identical, as you have noticed. Safariwatir obviously does not support accessing table cells via [].

See this link for details on getting Safari working with Watir-Webdriver

Chuck van der Linden
  • 6,660
  • 2
  • 28
  • 43
Željko Filipin
  • 56,372
  • 28
  • 94
  • 125
  • Thanks for the response...So how do I access the text in a cell table? – Brad Askins Dec 08 '11 at 13:29
  • Safariwatir is not in active development. I tried using `row` and `cell` to access the cell, but as far as I remember it did not work. I would suggest that you use watir-webdriver (but it can not drive Safari). – Željko Filipin Dec 08 '11 at 14:05
  • Thanks for the response. I was trying to get Safari to work because the person I wrote the script for could not get watir-webdriver to work. We actually got it to work a few minutes ago...so bye bye Safari :-) the problem we had with wedriver was this failed sudo gem install watir-webdriver --no-ri --no-rdoc but leaving off --no-ri --no-rdoc made the install successful and work – Brad Askins Dec 08 '11 at 16:38
  • Be aware that watir-webdriver now supports safari see http://watirwebdriver.com/safari/ – Chuck van der Linden Apr 18 '12 at 19:23