Getting Status Bar Panes' Text

Applies to TestComplete 15.20, last modified on January 13, 2022

Status bar panes can contain various information about the application. You may need to get this information to process it in a special way.

While testing status bar controls, you can use specific properties and methods of the corresponding program object to perform certain actions and obtain data stored in controls. You can call these methods and properties from your keyword tests, as well as from scripts. This topic describes how to work with the needed properties and methods from your scripts. However, when testing a control from your keyword test, you can use the same methods and properties calling them from keyword test operations. For more information, see Keyword Tests Basic Operations.

The Win32StatusBar object provides a set of properties and methods that allow you to obtain this information and perform various actions over the tested status bar controls. TestComplete associates this object with all status bar controls whose class names are listed in the Object Mapping list of the project’s options.

You can obtain text of a status bar pane via the wText property. You should specify the needed pane by its index. The following sample code obtains the text of the first pane and posts it to the test log:

JavaScript, JScript

function Main()
{
  var p, w, StatusBar;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys.Process("Explorer");
  w = p.Window("ExploreWClass", "My Documents", 1);
  StatusBar = w.Window("msctls_statusbar32", "", 1);
  
  // Post the text of the first pane to the test log
  Log.Message(StatusBar.wText(0));
}

Python

def Main():

  # Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL)
  
  # Obtain the status bar control
  p = Sys.Process("Explorer")
  w = p.Window("ExploreWClass", "My Documents", 1)
  StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  # Post the text of the first pane to the test log
  Log.Message(StatusBar.wText[0])

VBScript

Sub Main
  Dim p, w, StatusBar

  ' Open My Documents
  Call WshShell.Run("explorer.exe", SW_NORMAL)
  
  ' Obtain the status bar control
  Set p = Sys.Process("Explorer")
  Set w = p.Window("ExploreWClass", "My Documents", 1)
  Set StatusBar = w.Window("msctls_statusbar32", "", 1)
  
  ' Post the text of the first pane to the test log
  Log.Message(StatusBar.wText(0))
End Sub

DelphiScript

procedure Main();
var 
  p, w, StatusBar: OleVariant;
begin
  // Open My Documents
  WshShell.Run('explorer.exe', SW_NORMAL);
  
  // Obtain the status bar control
  p := Sys.Process('Explorer');
  w := p.Window('ExploreWClass', 'My Documents', 1);
  StatusBar := w.Window('msctls_statusbar32', '', 1);
  
  // Post the text of the first pane to the test log
  Log.Message(StatusBar.wText(0));
end;

C++Script, C#Script

function Main()
{
  var p, w, StatusBar;

  // Open My Documents
  WshShell.Run("explorer.exe", SW_NORMAL);
  
  // Obtain the status bar control
  p = Sys["Process"]("Explorer");
  w = p["Window"]("ExploreWClass", "My Documents", 1);
  StatusBar = w["Window"]("msctls_statusbar32", "", 1);
  
  // Post the text of the first pane to the test log
  Log.Message(StatusBar.wText(0));
}

See Also

Working With Status Bar Controls
wText Property (StatusBar Controls)

Highlight search results