OLE error code 80020101 caused by execute_script of waitr

∥☆過路亽.° 提交于 2020-01-24 23:04:30

问题


I just tried this:$browser.execute_script("alert(\"aaa\")")

and then I get the error below:

h:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.2.0/lib/watir-classic/page-container.rb:46:in `method_missing': (in OLE method `execScript': ) (WIN32OLERuntimeError)
OLE error code:80020101 in <Unknown>
  Could not complete the operation due to error 80020101.HRESULT error code:0x80020009
  Exception occurred.
    from h:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.2.0/lib/watir-classic/page-container.rb:46:in `rescue in execute_script'
    from h:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-classic-3.2.0/lib/watir-classic/page-container.rb:39:in `execute_script'

Am I missing install something?


回答1:


The exception means that a javascript error occurred when running the script.

While it would be better to fix the script, but if you really want to ignore the exception, you could wrap it in a begin-rescue:

begin
    $browser.execute_script("asdfasd") 
rescue WIN32OLERuntimeError
    #Ignore javascript error that occurred
end

When the exception occurs, the rescue will catch it and allow the program to continue.




回答2:


Try if single quotes make it work:

$browser.execute_script("alert('aaa')")


来源:https://stackoverflow.com/questions/13698335/ole-error-code-80020101-caused-by-execute-script-of-waitr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!