Ignoring overlapping windows

Sometimes, at the point of scripts being executed in an application at hand, there are windows or other controls elements being simultaneously opened to overlap the controls elements that are being referred to by the scripts, at the given moment of time. As a result, in the log, there appear error messages.

Overlapping window is the window that overrides the controls element, which TestComplete is handling at the moment; however, it does not block the working with the controls element.

In this recipe, we will learn to rid ourselves of the previous-mentioned error in the simplest manner imaginable.

Getting ready

Launch a standard Windows Notepad application (C:Windows otepad.exe).

How to do it...

In order to deal with overlapping windows we need to perform the following steps:

  1. Create the following function:
    function testOverlappingWindow()
    {
      var wNotepad = Sys.Process("NOTEPAD").Window("Notepad", "*");
      edit = wNotepad.Window("Edit");
      edit.Keys("first string[Enter]");
      wNotepad.MainMenu.Click("Edit|Find...");
      edit.Click(100, 120);
      edit.Keys("second string");
      var wFind = Sys.Process("NOTEPAD").Window("#32770", "Find");
      wFind.Window("Button", "Cancel").ClickButton();
    }
  2. In the line edit.Click(100, 120); change the parameters that are being passed to the method so that the mouse-click would be made at a point close by the Find window (you might need several tries to find the correct coordinates). Launch the function.
  3. In the result, we will have the following error message in the log: There was an attempt to perform an action at point (802, 545), which is overlapped by another window.
  4. Now, open the properties of the project (right-click on the name of the project and navigate to Edit | Properties).
  5. Open the Playback group of settings.
  6. Enable the Ignore overlapping window option as shown in the following screenshot:
    How to do it...
  7. Launch the function again. This time, there are no errors in the log.

How it works...

First we try to run the function which clicks on an object which is hidden by another window. As a result, an error message is put to the log showing that overlapping window prevents TestComplete performing the click action.

After we had made changes to project options, the error wasn't sent to the log again.

The example with the Find window in Notepad shows that error with overlapping windows isn't critical, since the script keeps successfully on after posting an error. Another example of such a behavior is an invisible controls element, which is located above the targeted element in mind, however, not standing in the script's way. Since such messages in the log may hinder us, we can simply ignore them, as shown in this recipe.

There's more...

If the window is blocking script workings with the application, it is called Unexpected, not Overlapping. In Playback group of project settings, one can customize behavior of TestComplete at work with the same windows, and we will also get to grip with the way to process those from the scripts in Chapter 12, Events Handling.

See also

  • If you don't want to ignore all overlapping windows, but only some of them avail yourself of the Disabling certain error messages recipe in Chapter 12, Events Handling
  • To deal with Unexpected windows refer to the Handling unexpected windows, part 1 and Handling unexpected windows, part 2 recipes in Chapter 12, Event Handling
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.173.199