Created On:  12 June 2012

In some applications (particularly Silverlight applications) there may be an object, for example a link or button which is only visible on certain pages. Therefore even though the object is not visible; the object may still exist. This has the effect that SilkTest may locate the object even if it is not visible on the page; this can be proven by determining if the method .Exists() returns true when executed against the object even if the object is not visible on the page.

This type of issue can cause replay problems if you have added verification functionality to your test case in order to determine if the object is visible on a particular page. As unless an object is discarded or destroyed; then the method “.Exists()” or the property “IsEnabled()” will always return true.

To overcome this problem we have to find a way of determining if the object is visible as certain Silverlight objects do not support the IsVisible() property.

With Silverlight objects, the equivalent of “IsVisible()” is the inbuilt property “IsOffscreen()”. When the object is showing on a page IsOffscreen() will return a value of false – the object is not off the screen. Also, when the object is not showing on the page, IsOffscreen() will return a value of true – the object is off the screen.

The following test case provides an example of this:

Testcase isObjectVisible() appstate none
boolean bVisible = BowserWindow.BrowserApplication.Object.GetProperty("IsOffscreen")
 // will return true if the object is off the screen and false if it is on the screen
       if(bVisible==false)
 // code to select the object as it is visible

      If(bVisible==true)
 // code that is used if the object is not visible

Incident #2576448