royd
5 years agoRegular Contributor
Solved
Need help with 'GeneralEvents_OnLogError'
Hi All
I am trying to save the log when TestComplete encounters an error and stops. After much reading, searching I have this bit working.
function swceLogin(){
Browsers.Item("iexplore").Run("[APPLICATION URL]"); var browser = Sys.Browser("iexplore"); var page = browser.Page("*THC*"); var userName = page.FindChildEx("idStr", "txtUserName", 10, true, 10000); var userPass = page.FindChild("idStr", "txtPassword", 10); var btnLogin = page.FindChild("idStr", "lnkLogin", 10); userName.SetText("[USER]"); userPass.SetText("[PASSWORD]"); btnLogin.ClickButton(); var pName = page.FindChild("idStr", "Name", 15); //wrong valu for 'idStr' for the test to fail var btnSearch = page.FindChild("idStr", "ctl00_masterBodyContent_LinkButtonSearch", 15); pName.SetText("Morgan, Tom"); // test fails here btnSearch.ClickButton(); } function GeneralEvents_OnLogError(Sender, LogParams){ var sPath = "C:\\TestLog\\Log.mht"; if (aqFileSystem.Exists(sPath)) aqFileSystem.DeleteFile(sPath); Log.SaveResultsAs("C:\\TestLog\\Log.mht", lsMHT, false, lesCurrentTestItem); }
Problem is, the log does not contain the error message that caused the script to stop! Is there a way to save the log that includes the error message?
Thanks in advance for any help.
Hi,
Do you need to export the log at the moment when error occurs?
The reason of your problem is that the handler is called before the error is actually posted to the log. This gives you a chance to not post it to the log.
You may consider to set your Test Item to stop on error and move your code from the OnLogError handler to the OnStopTest one.