1

我一直在努力弄清楚为什么 Safari 没有从表格中获取单元格文本。

看来这应该有效

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 

我得到错误

/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 工作只是找到。

完全糊涂了!

谢谢你的帮助。

4

1 回答 1

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

于 2011-12-08T10:25:27.903 回答