Forum Discussion
BenY_1
14 years agoNew Contributor
Thanks for the pointer, Martin. I was trying to use it on a page object, so the error is legit then.
Here's the code:
try
{
strObjectType = "";
if ((oMyTestObject!= null) && (oMyTestObject.hasOwnProperty("objectType")))
{
strObjectType = oMyTestObject.objectType;
}
}
catch (oE)
{
// do nothing
}
Here, we implemented a try/catch to deal with the case where .hasOwnProperty throws an error. However, for some reason, when it does throw an error, it is not catch by the catch block. Instead, TestComplete just logs an "Unable to find the object hasOwnProperty("objectType")" and move on to execute the statement within the if block. The error causes the test to be marked as failed.
Any idea why the error is not caught by the catch block?
Here's the code:
try
{
strObjectType = "";
if ((oMyTestObject!= null) && (oMyTestObject.hasOwnProperty("objectType")))
{
strObjectType = oMyTestObject.objectType;
}
}
catch (oE)
{
// do nothing
}
Here, we implemented a try/catch to deal with the case where .hasOwnProperty throws an error. However, for some reason, when it does throw an error, it is not catch by the catch block. Instead, TestComplete just logs an "Unable to find the object hasOwnProperty("objectType")" and move on to execute the statement within the if block. The error causes the test to be marked as failed.
Any idea why the error is not caught by the catch block?
Related Content
- 3 years ago
- 11 years ago
- 6 years ago
- 10 years ago
- 12 years ago
Recent Discussions
- 9 hours ago
- 4 days ago