Forum Discussion

chrisb's avatar
chrisb
Regular Contributor
12 years ago
Solved

Help needed with scripting interface to current test log during test run

I've scripted an event handler for OnStopTest to email the project test run results. 



I'd assumed that the log would be compiled before the OnStopTest fires but that does not appear to be the case. Unfortunately I discovered through trial and error and reading documentation that there is no scripting interface to the test log of the current run. 



Am I correct in thinking that we would need to have a second script that runs after our test run is completed (Event Handlers and all)  to email the test results out?



http://support.smartbear.com/viewarticle/55140/?_ga=1.145209844.1554134704.1392816096



I look forward to anyone's suggestions!
  • I believe you can call a savelogfile method Log.SaveResultsAs() and attach to an email. As a solution to this problem I actually create my own HTML log with just errors/warnings listed by using the onerror and onwarning events (is cleaner than the built in log & I can design it myself this way).

    As far as creating the email in JScript you can use something like this:






    function sendemail(mfrom,mto,msubject,mbody,mattach){



    mconfig = new ActiveXObject('CDO.Configuration');


    mconfig.fields.item(schema + 'sendusing') = 2; //cdoSendUsingPort;


    mconfig.fields.item(schema + 'smtpserver') = //SMTP server


    mconfig.fields.item(schema + 'smtpserverport') = 525; // Port number


    //mConfig.Fields.Item(schema + 'sendusername') = ''; // User name (if needed)


    //mConfig.Fields.Item(schema + 'sendpassword') = ''; // User password (if needed)


    mconfig.fields.update();


    message = new ActiveXObject('CDO.Message');


    message.configuration = mconfig;


    message.from = mfrom;


    message.to = mto;


    message.subject = msubject;


    message.htmlbody = mbody;

    message.addattachment mattach;


    message.send(); //Send Email


    }





11 Replies

  • Ryan_Moran's avatar
    Ryan_Moran
    Valued Contributor
    Also an interesting issue. I guess I don't see this because my scripts are organized in a hierchary? I really only have one testitem that calls 1 script and that main script drives all other scripts. I suppose you could add the Log.ErrCount/Log.WrnCount to each one and add them into a global variable. The problem with counting errors in the events is that the events, OnLogError for example, will not fire if a run time error is encountered.