VisibleOnScreen Property

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

Description

Specifies whether the whole object or any of its parts is currently visible on screen.

Declaration

TestObj.VisibleOnScreen

Read-Only Property Boolean
TestObj A variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section

Applies To

All onscreen objects.

View Mode

To view this property in the Object Browser panel and in other panels and dialogs, activate the Advanced view mode.

Property Value

True if any part of the object is currently visible on screen, otherwise False.

Remarks

  • The VisibleOnScreen property returns true, if a control or its part is on screen and can accept mouse clicks. For example, focused controls whose opacity is set to 0 are absolutely transparent (that is, invisible), but their VisibleOnScreen property will return true.

  • The VisibleOnScreen property is always false for disabled Silverlight controls.

  • The Name Mapping repository of your project uses various object properties to identify objects in your tested application. We do not recommend that you use VisibleOnScreen as an object identification property. It can take much time for TestComplete to get the property value that can significantly decrease your test performance, especially if the Extended Find is used.

    For the same reason, we do not recommend that you use the VisibleOnScreen property in search criteria of the Find, FindChild, FindAll, and FindAllChildren methods. TestComplete will have to get the value of this property of every object it checks when calling the methods that can decrease your test performance.

Example

The following example demonstrates how to use the VisibleOnScreen property in scripts:

JavaScript, JScript

var w = Sys.Process("Notepad").Window("Notepad");

if (w.VisibleOnScreen)
  w.Window("Edit").Keys("Test")
else
Log.Error("The Notepad window is invisible.");

Python

w = Sys.Process("notepad").Window("Notepad")
  
if (w.VisibleOnScreen):
  w.Window("Edit").Keys("Test")
else:
  Log.Error("The Notepad window is invisible")

VBScript

Dim w
Set w = Sys.Process("Notepad").Window("Notepad")

If w.VisibleOnScreen Then
  w.Window("Edit").Keys("Test")
Else
  Log.Error "The Notepad window is invisible."
End If

DelphiScript

var w;
begin
  w := Sys.Process('Notepad').Window('Notepad');

  if w.VisibleOnScreen then
    w.Window('Edit').Keys('Test')
  else
     Log.Error('The Notepad window is invisible.');
end;

C++Script, C#Script

var w = Sys["Process"]("Notepad")["Window"]("Notepad");

if (w["VisibleOnScreen"])
  w["Window"]("Edit")["Keys"]("Test")
else
   Log["Error"]("The Notepad window is invisible.");

See Also

Enabled Property
Visible Property
Focused Property (Window and BrowserWindow Objects)

Highlight search results