Small Cheese

The QTP Statement To Check The Object Whether Is Visible Or Invisible Mode

When we perform eye-ball testing, we can easily identify whether the object is visible or invisible, but how do we instruct QTP to check that the particular object whether is visible or invisible and return the correct result.

There are some solutions to do such checking but depending on how the programmer codes the application.

Here are the scenario I tested before.

Scenario 1
1. When page loading, the button is enabled
2. After clicked on the button, that button will be disabled.

Script
If (SwfWindow("").SwfWindow("").SwfObject("").GetROProperty ("enabled")) then
   createobject("WScript.shell").Popup "The button is enable",5
else
   createobject("WScript.shell").Popup "The button is unable",5
End if

You may also use this for testing
If (Browser("").Window("").Page("").Link("").Object.currentStyle.display = "block") then
   createobject("WScript.shell").Popup "The button is unable",5
else
   createobject("WScript.shell").Popup "The button is enable",5
End if

Scenario 2

1. When page loading, the button is enabled
2. After clicked on the button, that button will be hidden.

Script
None = the button is invisibled
If (Browser("").Window("").Page("").Link("").Object.currentStyle.display = "none") Then
   createobject("WScript.shell").Popup "The button is invisible",5
else
   createobject("WScript.shell").Popup "The button is visible",5
end if


Custom Search