OLE error code 80020101 caused by execute_script of waitr

1

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?

watir
ole

2 Answers

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.

answered on Stack Overflow Dec 5, 2012 by Justin Ko
0

Try if single quotes make it work:

$browser.execute_script("alert('aaa')")
answered on Stack Overflow Dec 6, 2012 by Jarmo Pertman

User contributions licensed under CC BY-SA 3.0