We are building a new experience for our SmartBear Community.
This site is now read-only. You can still browse and search as usual. Learn More
This site is now read-only. You can still browse and search as usual. Learn More
I'm not sure this is exactly a Python problem. I see two potential issues with the code.
1) What if FindChildByXPath actually returns an empty stub object? That object does not have the "VisibleOnScreen" property. Errors like that don't raise as "exceptions", those are object recognition errors that need to be handled differently. What you should do is check "Exists", not "VisibleOnScreen", if Exists is true, then you can do any other checks you want.
2) You're doing a search by XPath. VisibleOnScreen is a property that TestComplete applies to distinct objects. Finding an object by XPath does not ALWAYS return an object that TestComplete can interact with as a UI object so it might not even have the VisibleOnScreen property. Again... this would be an object recognition error, but with a different root cause. This would not raise an exception and would not go into the except block.
Python guru, any suggestions?
sriram_sig, please take a look at this article as well:
https://support.smartbear.com/testcomplete/docs/scripting/handling-exceptions.html#Python