jarmo/RAutomation — Issue #29: An Issue of Timing
Author: enkessler
Created: 2011-10-26 20:33:27+00:00
State: open

Here's a little experiment:

1. Open up an application window.
2. Locate that window (by :title for the sake of argument) and store it in a handy variable.
3. Check if it #exist?.
4. Close the window.
5. Reopen/relaunch the application window.
6. Check if it #exists? again using the same variable.

According to RAutomation the window will not exist the second time. You won't be able to click buttons or grab values or anything else for that matter either because the instance of Window that the variable points to was fixed to a specific instance of a matching application window.

Here is the offending piece of code by the way:

# Retrieves handle of the window.
# @note Searches only for visible windows.
# @see RAutomation::Window#hwnd
def hwnd
@hwnd ||= Functions.window_hwnd(@locators)
end

Since most of the internal operations of a Window are handled via its @hwnd, as soon as you use it the first time you are tied to one exact application window.

Is this desired? Shouldn't a given RAutomation::Window object be able to interact with any application window as long as its locators match?