How To Work With Automation Object Model In UFT?

1
460
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share


Private Function CloseAppliction()
Set objWMIService = GetObject("winmgmts:\.rootCIMV2")
Set colProcess = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = qlock.exe'")
For Each objProcess in colProcess
objProcess.Terminate()
Next
Set objWMIService = Nothing
Set colProcess = Nothing
End Function

 

Public Function fn_close_all_excel_files()
strComputer = "."
Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootcimv2")
Set colProcessList = objWMIService.ExecQuery ("Select * from Win32_Process Where Name = 'EXCEL.EXE'")
For Each objProcess in colProcessList
objProcess.Terminate()
Next
End Function
 

How to Connect QTP or UFT with QC?


Set qtApp = CreateObject("QuickTest.Application")
If qtApp.TDConnection.IsConnected Then
msgbox "QC"
Else
msgbox "Local"
End If
 

Another way:


if QCUtil.IsConnected then
Reporter.ReportEvent 0, "Connected", "Connected to server: " + QCUtil.QCConnection.ServerName + chr (13) +"Project: " +
QCUtil.QCConnection.ProjectName + chr (13) + "Domain: " + QCUtil.QCConnection.DomainName
else
Reporter.ReportEvent 1, "Not connected", "Not connected to Quality Center"
end if
 
Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share