Getting cell text from a table using Watir on Mac Safari

352 views Asked by At

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.

1

There are 1 answers

4
Željko Filipin On

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