Vapir has nothing particularly different with UAC. I wrote to this list, in
some detail, on this subject some time back:
http://rubyforge.org/pipermail/wtr-development/2009-October/001276.html
I have no problem with actually attaching, though, whether I run as
administrator or not. Just with an already-attached window navigating to a
local file. The short of it is that this can be solved by turning off
Protected Mode, or running ruby as administrator.
I don't know, maybe I'm mistaken as to what is actually at issue here. For
me, Robert's code runs fine for me whether or not I have administrator
integrity:
shell = WIN32OLE.new('Shell.Application')
shellWindows = shell.Windows
puts "window count = #{shellWindows.count}"
shell.Windows.each do |window|
puts "#{window.hwnd} #{window.path}" rescue false
end
Is this block doing something unexpected for other people?
-Ethan
On Fri, Sep 24, 2010 at 18:14, Jarmo <[email protected]> wrote:
> If you think of any good solution which would work for all cases then
> it would be superb.
>
> Ethan, is Vapir working differently with UAC?
>
> Jarmo
>
> On Thu, Sep 23, 2010 at 8:39 PM, Robert Pyron <[email protected]> wrote:
> > This block of code does not play nicely when User Account Control (UAC)
> is
> > turned on.
> >
> > shell = WIN32OLE.new('Shell.Application')
> > shell.Windows.each do |window|
> > ...
> > end
> >
> > When I turn off UAC, all Watir unit tests (except one) run correctly,
> > regardless of whether I am running as Administrator.
> >
> >
> >
> >
> > require 'rubygems'
> > require 'watir'
> > Watir::Browser.default = 'ie'
> >
> > # Open a bunch of windows
> > [
> > 'http://www.ruby-lang.org/en/',
> > 'http://watir.com/',
> > 'http://google.com',
> > ].each do |url| Watir::Browser.start(url) end
> >
> > # Enumerate the windows. This is a stripped-down version of
> > # the loop that is eventually called by Watir::IE#attach.
> > #
> > # The expectation is that every one of the pages we just opened
> > # will show up in this list, each in a separate window.
> > #
> > # What actually happens depends at least on OS version, User Account
> Control
> > # settings, and whether the script is being run from an Administrator
> > # command prompt.
> > #
> > # OS = XP all windows are enumerated
> > # OS = Vista probably the same as Windows 7; untested (by me)
> > # OS = Windows 7
> > # UAC off all windows are enumerated
> > # UAC on, not running as Admin all windows are enumerated
> > # UAC on, running as Admin only the first window is enumerated
> > #
> > Watir::IE.each do |ie|
> > window = ie.ie
> > puts "#{window.locationURL} #{window.locationName}"
> > end
> > puts
> >
> > # Watir::IE.each is looking for 'Internet Explorer' as part of the
> > # window path, so let's enumerate those.
> > #
> > puts '----------------'
> > shell = WIN32OLE.new('Shell.Application')
> > shellWindows = shell.Windows
> > puts "window count = #{shellWindows.count}"
> > shell.Windows.each do |window|
> > puts "#{window.hwnd} #{window.path}" rescue false
> > end
> > puts
> >
> >
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > Wtr-development mailing list
> > [email protected]
> > http://rubyforge.org/mailman/listinfo/wtr-development
> >
> _______________________________________________
> Wtr-development mailing list
> [email protected]
> http://rubyforge.org/mailman/listinfo/wtr-development
>
_______________________________________________
Wtr-development mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/wtr-development