未来已来

hp-WinRunner 百问 二

上一篇 / 下一篇  2008-10-05 16:26:15 / 个人分类:自动化测试

  

    WinRunner使用TSL脚本,主要是类c的语法,wr调用com对象难度比较大,这里利用另类办法调用底层com对象,主要利用wr中file的操作以及dos_system的调用方法,实现,通过这种方法可以加强wr的脚本扩展能力的缺陷。例子如下:

public function send_outlook_mail(in to, in cc, in bcc, in subject, in body, in attach)
{
auto i, scrīpt;

scrīpt = getvar("exp") & "\\send_outlook_mail.vbs";

file_open(scrīpt,FO_MODE_WRITE);
file_printf(scrīpt,"Dim objOutlook\r\n");
file_printf(scrīpt,"Dim objOutlookMsg\r\n");
file_printf(scrīpt,"Set ōbjOutlook = CreateObject(\"Outlook.Application\")\r\n");
file_printf(scrīpt,"Set ōbjOutlookMsg = objOutlook.CreateItem(olMailItem)\r\n");
file_printf(scrīpt,"objOutlookMsg.To = \"%s\"\r\n", to);
file_printf(scrīpt,"objOutlookMsg.CC = \"%s\"\r\n", cc);
file_printf(scrīpt,"objOutlookMsg.BCC = \"%s\"\r\n", bcc);
file_printf(scrīpt,"objOutlookMsg.Subject = \"%s\"\r\n", subject);
file_printf(scrīpt,"objOutlookMsg.Body = \"%s\"\r\n", body);
file_printf(scrīpt,"objOutlookMsg.attachments.add \"%s\"\r\n", attach);
file_printf(scrīpt,"objOutlookMsg.Send\r\n");
file_close(scrīpt);
dos_system("wscrīpt \"" & scrīpt & "\"");
#dos_system("del \"" & scrīpt & "\"");
return(E_OK);
}

Example:

send_outlook_mail("pcl@51testing.com.com","","","Daily reports","Winrunner scrīpt to check the status of Daily reports is Completed.Check the results attached.Thanks.",file);

 


TAG: 自动化测试

 

评分:0

我来说两句

Open Toolbar