在 Mac Safari 上使用 Watir 从表格中获取单元格文本
我一直在绞尽脑汁地试图找出为什么 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 Works just find 。
完全糊涂了!
感谢您的帮助。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用 Watir-Webdriver gem 来驱动 Chrome 和 Safari,它应该可以解决您的问题。
正如您所注意到的,Safariwatir 和 Watir-Webdriver 有类似的 API,但并不完全相同。 Safariwatir 显然不支持通过
[]
访问表格单元格。有关让 Safari 与 Watir-Webdriver 配合使用的详细信息,请参阅此链接
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