vbace2
14 years agoOccasional Contributor
Object does not exist error handling / close IE
I apologize if this has been answered before, or if this can be found elsewhere. I am a newbie to TC and I tried to search the help files and forums.
So, we purchased TC about 6 months ago, and we only had two test cases created. The person who was using it before, and who had been trained on it, had their priorities/responsibilities changed. So, I am the lucky one who is trying to utilize TC. So, I wanted to start off with something simple. I recorded a test that would start up a login page in IE, a user name and password is entered and the submit button is pressed. The new page opens. A web comparison is performed to make sure the correct place is reached. The logout link is pressed. Another web comparison is performed to make sure they were logged off. This all seems to work fine. When recorded, I selected to have this saved as JScript.
I went into the test and changed the password so that the user would not be able to log in successfully and get to the correct place. When I run the test case, it waits for the login to process but then fails with "The object does not exist. See Remarks for details." The remarks say that an error occurred while call the "Wait" method or property of the "pageloginpage" object. Of course this makes sense to me since it didn't get to the expected page. When this happens, the test script ends and leaves IE open on the machine.
So, I tried using JScript try/catch to catch the error and then close IE. If IE doesn't close, it causes issues when trying to run subsequent test cases. It doesn't seem that the try catch gets executed when this runs. I even tried the following to see if I was getting into the catch or finally blocks...
function test()
{
try {
all code here to open IE, try to login, etc. etc
}
catch(e) {
Log.Error("reached error");
}
finally {
Log.Message("reached finally");
}
}
If I have the correct password and the test goes through all the scripts, I get the message from the finally block. However, if I have the wrong password and I get the "object does not exist" error, I don't get the catch message or the finally message. It seems that TC job stops processing at that point.
So, is there a way to catch this error and perform processing (like closing IE)?
Thanks
So, we purchased TC about 6 months ago, and we only had two test cases created. The person who was using it before, and who had been trained on it, had their priorities/responsibilities changed. So, I am the lucky one who is trying to utilize TC. So, I wanted to start off with something simple. I recorded a test that would start up a login page in IE, a user name and password is entered and the submit button is pressed. The new page opens. A web comparison is performed to make sure the correct place is reached. The logout link is pressed. Another web comparison is performed to make sure they were logged off. This all seems to work fine. When recorded, I selected to have this saved as JScript.
I went into the test and changed the password so that the user would not be able to log in successfully and get to the correct place. When I run the test case, it waits for the login to process but then fails with "The object does not exist. See Remarks for details." The remarks say that an error occurred while call the "Wait" method or property of the "pageloginpage" object. Of course this makes sense to me since it didn't get to the expected page. When this happens, the test script ends and leaves IE open on the machine.
So, I tried using JScript try/catch to catch the error and then close IE. If IE doesn't close, it causes issues when trying to run subsequent test cases. It doesn't seem that the try catch gets executed when this runs. I even tried the following to see if I was getting into the catch or finally blocks...
function test()
{
try {
all code here to open IE, try to login, etc. etc
}
catch(e) {
Log.Error("reached error");
}
finally {
Log.Message("reached finally");
}
}
If I have the correct password and the test goes through all the scripts, I get the message from the finally block. However, if I have the wrong password and I get the "object does not exist" error, I don't get the catch message or the finally message. It seems that TC job stops processing at that point.
So, is there a way to catch this error and perform processing (like closing IE)?
Thanks