Close any open browsers by VB Script QTP 11

It's always a best practise to close any other open browsers before my actual QTP scripts start. To acheive that, just follow these easy steps

1. Download Windows Sysinternal tools from Microsoft website
Link: https://technet.microsoft.com/en-us/sysinternals/pskill.aspx



2. Store pskill.exe in some folder in C Drive (For Example "C:\TestingProject\Source\QTPTests\VBA\Sysinternal\")

3. Use this code :-)
Set objShell = CreateObject("WScript.Shell") 
pskillLocation = "C:\TestingProject\Source\QTPTests\VBA\Sysinternal\"

'Kill any open IE browser
objShell.Run (pskillLocation & "pskill.exe iexplore.exe")
wait 2

'Kill any open Firefox browser
objShell.Run (pskillLocation & "pskill.exe firefox.exe")
wait 2

'Kill any open chrome browser
objShell.Run (pskillLocation & "pskill.exe chrome.exe")
wait 4

Comments

Popular posts from this blog

How to maximize FireFox browser from QTP

How to search and click a link in a WebTable?

How to take screenshot of failed QTP step?