Wednesday, December 19, 2018

Test Complete / UFT-Run functions dynemic through excel files

Hey folks,

sometimes functions execution flow needs to controll through excel files and need to run the functions dynemic, so hope this line of code will help. Same applies to UFT as well.

in excel sheet, for exampme TC1 having FUNC1-10 then,

for fncnt=1 to sheet. columncount
    strfunctionname=""
    if(aqconvert. vartostr(fncnt)) <>"" then
         strfunctionname=aqconvert. vartostr(testcasedriver. value(fncnt))
        functiontorun="Call" & strfunctionname
       execute functiontorun
    end if
next

wishes,
Trupti

Test Complete-Terminate window application or exe using vbscript

dim process, strprocesstokill, strobject, strcomputer

strcomputer="."
strobject="winmgmts://" & strcomputer
'To kill multiple instance like excel or anything use for loop else use without for loop
for each process in getobject(strobject). instanceof("win32_process")
       if (sys. waitprocess(strprocess), 0).exists) then
              sys. process(strprocess). Terminate()
       End if
Next

Tuesday, December 18, 2018

Send Email through vbs using CDO object

set  objemail=createobject("cdo. message")
objemail. from=strmailfrom
objemail. to=strmailto
objemail. subject=strmailsubject
objemail. textbody=strmailbody
strmailattachment="c:\test. btml"
objemail. addattachment strmailattachment
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="mailhost. ldn... com"
objemail. configuration. fields. item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
objemail. configuration. fields. update
objemail. send

Send email through vbs using Outlook Application utility object

set objoutlookmail=createobject("outlook. application")
Set mymail=objoutlookmail. createitem(0)
mymail.display
set mymailproperty=objoutlookmail. activeinsepector
if mymailproperty. iswordmail="trur" then
    set mydoc=mymailproperty. wordeditor
    mydoc. range chr(13)+"Hi All," +chr(13) & " Please see execution status for.... application." +chr(13)
     mydoc.range.insertafter chr(13)+"Regards,"+chr(13) & "support team" +chr(13)
     strmailattachment="c:\test. html"
      mymail. Attachments. add strmailattachment
       mymail. from="abc@gmail.com"
       mymail. to="xyz@gmail.com;pyz@gmail.com"
      mymail. subject="Application Automation Execution Reports"
       mymail. send
end if
Set mymail.=Nothing
Set mydoc=Nothing
Set objoutlookmail=Nothing