Forum Discussion

rlent's avatar
rlent
Contributor
13 years ago

Bringing a window to the front?

I am testing an application, and the script can't find the window to click the OK button, because the dialog gets shoved to the back. That's a bug in the application, but I have to test around this bug. Because the dialog is shoved to the back, there is an error which says there is an overlapping window. Is there a way to force the window to the front?
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3
    Hi Robert,



    For the objects that can be put to the front (usually these are windows) you can call the .Activate() method (i.e. use <window>.Activate() code line).

    For the objects that cannot be put to the front (e.g. edit boxes on the form) you can call the .SetFocus() method.



    As a side note: I consider calling these methods to be a good test coding practice because if the window cannot be activated (e.g. because it is overlapped by some another *modal* window) the OnUnexpectedWindow event (see relevant help topic for more details) will be called giving you the chance to analyze if the problematic window is a problem or not and either post an error in the former case or just close it gracefully in the latter case and continue running the test.