Ask a Question

Save As Log.mht rename file name as a date. Then send out email.

romanmfs
Frequent Contributor

Save As Log.mht rename file name as a date. Then send out email.

Hi!

I am beginner and only work with keyword cases have very basic understanding about scripts.

 

THINGS I NEED TO DO:

 

1. Save report as today's_date.mht

2. Automatically send out an email after report document created.

 

THINGS WHAT I'VE DONE:

1. Created 2 scripts for "save as" and it works 

2. Created a script for email automation and it give an error.

 

THINGS WHERE I'M STUCK:

 

1. Here is my "save as script" and it works but can somebody please help me to be able to save it as 'todays date' everytime.

 

function Test()

{
// Saving file
// ...

Log.SaveResultsAs("V:\\TestComplete\\Reports\\Report.mht", lsMHT);
}

 

2. Here is my script for email automation (outgoing server is correct etc), but I get an error: screenshot

I'm trying to use our Outlook mail which is installed locally.

 

function Test()
{
if (SendMail("rmarchuk@venturetechsolutions.com", "relay.ventureresource.local", "Roman Marchuk", "romanmfs@yahoo.com",
"Notification", "Hello QA, Your website is beautiful.", "V:\\TestComplete\\Reports\\Report.mht"))
Log.Message("Mail was sent");
else
Log.Warning("Mail was not sent");

}

 

 

Can somebody please help me I've been going back and forward with this for like 2 weeks now 😞

 

 

 

12 REPLIES 12
romanmfs
Frequent Contributor

Anybody?

 

You'll need to use

 

aqConvert.DateTimeToStr(aqDateTime.Today())

 

to get the string you need for the file name


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
liquidphantom
Occasional Contributor

I wrote this vb script for my log files "strPrefix" refers to a variable I have that prefixes a the file with Passed, error, timeout etc depending on a flag set in one of the general events.

 

It will create a TestExecuteLogs folder in root c:\ and a date stamped folder in there, in those folders each log will have a datetime stamp in the file name.

 

 

Sub SaveLog
    Dim CurDate, CurTime, strCurDate, strCurTime, strFolder, strFile, strPrefix, strLogPath

    strPrefix = Project.Variables.strLogPrefix
    
    strLogPath = ProjectSuite.Variables.strSuitePath
    
    'get current date and time 
    CurDate = aqDateTime.Today
    CurTime = aqDateTime.Time
    
    'convert current date and time       
    strCurDate = aqConvert.DateTimeToFormatStr(CurDate, "%Y%m%d")
    strCurTime = aqConvert.DateTimeToFormatStr(CurTime, "%H%M%S")
    
    strCurTime = Replace(strCurTime, ":","-")
    
    Log.SaveToDisk
    'Log save breakpoint

    'Save log out to mht package
    strFolder = "C:\TestExecuteLogs\" & strCurDate &"\" 
    strFile = strPrefix & "Log" & "_" & strCurDate & "_" & strCurTime & ".mht"
    
    If aqFileSystem.Exists(strFolder) = True Then
        Call Log.SaveResultsAs(strFolder & strFile, lsMHT)
    End If
    
    If aqFileSystem.CreateFolder(strFolder) = 0 Then
        Call Log.SaveResultsAs(strFolder & strFile, lsMHT)
    End If
End Sub

 

 

cancel
Showing results for 
Search instead for 
Did you mean: