今天是我第二天搞Watir,写了一段简单的代码:
结果ruby报错:
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/frame.rb:52:in `method_missing': document (WIN32OLERuntimeError)
OLE error code:80070005 in <Unknown>
拒绝访问。
HRESULT error code:0x80020009
发生意外。 from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/frame.rb:52:in `document'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/page-container.rb:31:in `page'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/page-container.rb:37:in `html'
from watir_test_1.rb:11
结果在一位高手的指导下,把站点添加到IE的信任站点就可以了
这个问题的主要原因是 JS跨域访问的问题
ie.goto("http://130.34.98.11:18080/bssframe"); ie.text_field(:id,"STAFF_ID").set("SUPERUSR"); ie.text_field(:id,"PASSWORD").set("XXXXXX"); ie.button(:id,"bLoginSubmit").click; contentFrame = ie.frame(:id,"contentframe"); puts contentFrame.html;
结果ruby报错:
c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/frame.rb:52:in `method_missing': document (WIN32OLERuntimeError)
OLE error code:80070005 in <Unknown>
拒绝访问。
HRESULT error code:0x80020009
发生意外。 from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/frame.rb:52:in `document'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/page-container.rb:31:in `page'
from c:/ruby/lib/ruby/gems/1.8/gems/watir-1.5.4/./watir/page-container.rb:37:in `html'
from watir_test_1.rb:11
结果在一位高手的指导下,把站点添加到IE的信任站点就可以了
这个问题的主要原因是 JS跨域访问的问题