Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ok, I have solved my own issue. </p> <p>It turns out that the method that Watir uses to enumerate IE windows (i.e. Shell.Application) does not work across user spaces. So I had to write an intermediate application to retrieve the IWebBrowser2 COM pointer for the IE window, and modify the 'eval_in_spawned_process' Watir function to use this handle for 'pc = Watir::IE.bind(iWebBrowserPtr)'.</p> <p>It's possible that I didn't need the external app to retrieve the IWebBrowser2 object, but I didn't know how to do it in Ruby, and I already had an IE BHO app that I could leverage for the purposes.</p> <p>This now works fine. :)</p> <p>Watir/page-container.rb:56</p> <pre><code># This evaluates a cmd (e.g. "button(:id, 1).click!") in a new ruby process # This is to primarily avoid a script hanging while a modal dialog is displayed in IE. # It gets an IE handle from our IE BHO based off of window handle. It needs to do this # to get around the problem of finding the IE window itself using Shell.Application # which does not work across User-contexts. # Note: This change probably invalidates the Watir unit-test for this API. def eval_in_spawned_process(command) command.strip! load_path_code = _code_that_copies_readonly_array($LOAD_PATH, '$LOAD_PATH') ruby_code = "require 'watir/ie'; " ruby_code &lt;&lt; 'controller = WIN32OLE.new("HttpPlugin.Controller"); ' ruby_code &lt;&lt; "window = controller.BrowserFromHWND(#{hwnd}); " ruby_code &lt;&lt; "pc = Watir::IE.bind(window); " ruby_code &lt;&lt; "pc.#{command}; " exec_string = "start rubyw -e #{(load_path_code + '; ' + ruby_code).inspect}" result = system(exec_string) end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload