[Wtr-development] new window automation library: WinWindow

Jarmo jarmo.p at gmail.com
Thu Sep 2 07:13:41 EDT 2010


Hi, Ethan!

I've taken a glimpse on that thing now. Really, a glimpse.

First of all, i think that it's somehow great if something else (ffi
in this case) is used instead of AutoIt. On the other hand with AutoIt
a lot of problems are already solved. So there are two sides for this
approach.

It's great that it is nicely documented :)

>From a developer's view i don't like that (almost) all the code is in
one file with 1365 lines. Why?

As a user's view i looked at the API and it seems to be really-really
(i mean, really) confuzing. For example, there are methods like
#set_foreground! and #really_set_foreground!. Like, what?

On another note, i've been lately producing some code using AutoIt
since it is nicely integrated with current Watir. I'm being able to
produce quite robust and effective results with it. I don't see many
benefits of using something else currently (yup, you cannot use
everything with AutoIt on locked workstation, but this is also true
for FFI and something similar). Anyway, i'm planning to make it as a
gem also probably.

Sorry, if i'm not able to see the big picture.

Keep up the good work!

Jarmo

On Wed, Sep 1, 2010 at 6:35 PM, Ethan <notethan at gmail.com> wrote:
> I've released a gem for a ruby library that I hope people will find useful,
> and I believe will be of interest to those using watir. The library is
> called WinWindow, and its aim is to represent a window (such as an IE
> window, or a javascript popup), and expose windows API methods in an
> object-oriented, ruby-like way.
> The project's site is at http://winwindow.vapir.org/
> It was borne of frustration with winClicker and AutoIt, and I wrote it to
> replace, improve, and expand on functionality that watir currently uses
> those libraries for. Namely, interaction with modal dialogs (getting text,
> entering text, clicking buttons, closing); maximizing/focusing windows;
> dealing with File Upload dialogs. It also does screen captures, which I
> implemented because the win32screenshot gem was broken, although Jarmo has
> since fixed that gem.
> Some sample code showing use with watir, to close a javascript popup,
> follows:
> $ irb -r watir
>>> require 'winwindow'
> => true
> # launch a new browser
>>> ie=Watir::IE.new
> => #<Watir::IE:0x36fece8 url="about:blank" title="">
> # create a WinWindow representing the browser
>>> w=WinWindow.new(ie.hwnd)
> => #<WinWindow:0x36e3688 @text="Blank Page - Windows Internet Explorer",
> @hwnd=395016, @class_name="IEFrame">
> # go to a site that'll give us a javascript popup
>>> ie.goto
>>> "http://www.mediacollege.com/internet/javascript/basic/alert.html"
> => 2.953125
> # click the button to create the popup
>>> ie.button(:value, /alert/).click_no_wait
> => ""
> # see if the popup is on the window
>>> w.enabled_popup
> => #<WinWindow:0x3642810 @text="Windows Internet Explorer", @hwnd=15076272,
> @class_name="#32770">
> # click the "OK" button on the popup. the 'try_for' part tells it how many
> # seconds to try, because sending click messages through the windows API is
> # not very reliable and just doing it once tends to fail.
>>> w.enabled_popup.click_child_button_try_for!('OK', 4)
> => true
> # popup is gone.
> tl;dr version: to click on a button on ie's popup with text button_text
> (trying for n seconds), you can use
> WinWindow.new(ie.hwnd).enabled_popup.click_child_button_try_for!(button_text,
> n)
>
> I hope you'll give it a try and let me know what you think.
> -Ethan
> _______________________________________________
> Wtr-development mailing list
> Wtr-development at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wtr-development
>


More information about the Wtr-development mailing list