Forum Discussion
dpeterson157
11 years agoContributor
It drives me crazy that I can't add a "Visible" property check to my scripts that won't fail if the object doesn't happen to exist in a given scenario. Its even more exasperating if I'm trying to verify that the object isn't supposed to exist!
Consider:
Property Checkpoint(objX, "Visible", cmpEqual, true)
// Checkpoint should return success if the object is visible, failure if it is not
In practice, it works fine if the object is visible, but returns a runtime error if it is not (because the object is not visible. DUH!).
Property Checkpoint(objX, "Visible", cmpEqual, false)
// Checkpoint should return success if the object is NOT visible, failure if it is
In this case, the checkpoint ALWAYS logs a failure. If its not visible, a runtime error is logged (again, because its not visible). If it is visible, it logs an error because the object isn't supposed to be visible, which is actually correct.
This has always been a problem with "Visible" and similar properties in every automation system I'm familiar with. Upon my first exposure to TestComplete, I had hoped that the issue would have been addressed in a logical manner. Alas, that is not the case.
A special case needs to be added to the code for property checkpoints where "Visible" and similar properties are concerned, specifically:
if (property_checked = "Visible", "VisibleOnScreen", etc) {
if (expectedValue = false) {
if (!object.Exists) {
log success;
return true;
} else {
// process normally
}
} else { // expectedValue = true
if (!object.Exists) {
log failure;
return false;
} else {
// process normally
}
}
}
Bottom line is that there is no good reason whatsoever why executing a property check against the Visible property should ever generate a run-time error. EVER!
Consider:
Property Checkpoint(objX, "Visible", cmpEqual, true)
// Checkpoint should return success if the object is visible, failure if it is not
In practice, it works fine if the object is visible, but returns a runtime error if it is not (because the object is not visible. DUH!).
Property Checkpoint(objX, "Visible", cmpEqual, false)
// Checkpoint should return success if the object is NOT visible, failure if it is
In this case, the checkpoint ALWAYS logs a failure. If its not visible, a runtime error is logged (again, because its not visible). If it is visible, it logs an error because the object isn't supposed to be visible, which is actually correct.
This has always been a problem with "Visible" and similar properties in every automation system I'm familiar with. Upon my first exposure to TestComplete, I had hoped that the issue would have been addressed in a logical manner. Alas, that is not the case.
A special case needs to be added to the code for property checkpoints where "Visible" and similar properties are concerned, specifically:
if (property_checked = "Visible", "VisibleOnScreen", etc) {
if (expectedValue = false) {
if (!object.Exists) {
log success;
return true;
} else {
// process normally
}
} else { // expectedValue = true
if (!object.Exists) {
log failure;
return false;
} else {
// process normally
}
}
}
Bottom line is that there is no good reason whatsoever why executing a property check against the Visible property should ever generate a run-time error. EVER!
Related Content
- 3 years ago
Recent Discussions
- 4 days ago
- 5 days ago