celerity 1.7.0还是不能很好的处理iframe

2012-08-01  王少平 

require "rubygems"
require "celerity"

browser = Celerity::Browser.new


=begin
进行celerity对frame的操作试验.
=end

require "celerity"

browser = Celerity::Browser.new

browser.goto('http://www.w3school.com.cn/tiy/t.asp?f=html_iframe')

puts browser.title

puts browser.frames.count
browser.frames[1].frames[1].exist? #=> true
browser.frames[1].frames[1].text 
browser.frames[1].frames[1].a.text 


puts browser.frames[2].html #=>可以看到下面有一个iframe
browser.frames[2].frames[1].exist? #=> 会直接报错.
# 错误信息如下:
=begin 
NoMethodError: undefined method `getDocumentElement' for #<Java::ComGargoylesoft
wareHtmlunit::UnexpectedPage:0x1021e58>
        from c:/jruby/lib/ruby/gems/shared/gems/celerity-0.9.2/lib/celerity/elem
ents/frame.rb:31:in `locate'
        from c:/jruby/lib/ruby/gems/shared/gems/celerity-0.9.2/lib/celerity/elem
ents/frame.rb:43:in `assert_exists'
        from c:/jruby/lib/ruby/gems/shared/gems/celerity-0.9.2/lib/celerity/elem
ent.rb:189:in `exists?'
        from (irb):114:in `evaluate'
        from org/jruby/RubyKernel.java:1037:in `eval'
        from org/jruby/RubyKernel.java:1353:in `loop'
        from org/jruby/RubyKernel.java:1146:in `catch'
        from org/jruby/RubyKernel.java:1146:in `catch'
        from c:\jruby\bin\irb:13:in `(root)'
=end
371°/3717 人阅读/0 条评论 发表评论

登录 后发表评论