Thursday, July 31, 2008

Use of Windows Scripting In Test Automation

Here is my second post, Lets have a look at the importance and adavantage of Wscript(Windows Scripting) in Test Automation.

For every automation test script the pre-condition is to launch the application under test.

At times i observed that there will be conflicting while launching the application using the built in methods provided by the automation tools like QTP(Systemutil.Run) and TestComplete(TestedApps.Item.Run) etc.

The main reason for these type behaviors was the type libraries or add-ins associated with the tool conflicts with application, so application cant be launched in such type of scenarios. These type of behaviors i have observed especially with Java applications.

To overcome with this problem we need some mechanism to laucnh the applications out of automation tools scope.

Here is the Windows Scripting object provides with number of useful methods.

Syntax Call LaunchApplication(application path)

e.g. Call LaunchApplication("c:\Program Files\Internet Explorer\IEXPLORE.EXE")

Sample code to launch a application using Windows scripting shell object
----------------------------------------------------------------------
Sub LaunchApplication(strAppPath)

Dim objWso

Set objWso = CreateObject("WScript.Shell")
Call objWso.Run(strAppPath) (or)
'To launch from a command prompt
objWso.Run "cmd /k " & strAppPath

Set objWso = Nothing
End Sub

1 comment:

Anonymous said...

Nice work Raj...all this info is very helpful