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

Saturday, July 19, 2008

Magic of temp in Automation

Hey,

All of earlier posts were not of my own writings, i just searched on net and extracted whatever i feel essential and useful for testers in automation.

Today is my turn to write my own experice in test automation.

Topic is use of temp folder/file in automation

At times we need to create temporary folders/files to store some intermediate data or content for computation during course of execution time.

Here is a simple scripts will be helpful in creating a folder or file as per your requirement.

Sysntax to use the below code: Call CreateTemp(folderorfilepath,folder/file)

E.g. To create a folder - Call CreateTemp("c:\temp\test\storetemp\","folder")
E.g. To create a file -Call CreateTemp("c:\temp\test\storetemp\storeresults.txt","file")

'******************************************************
' Name of the Function : CreateTemp
' Functionalty : To create a temporary folder/file
' Created By : Rajesh
' Created On : 19th July 08
' Input Parameter :
' 1. strPath: Path of the file system object (file/folder)
' 2. strFSO: Type of file system object. Possible values are FILE/FOLDER
' Return Value : NA
'********************************************************
Sub createtemp(strPath,strFSOType)
On Error Resume Next

Dim objFso 'ref object for file system

'Set referemce to file system object
Set objFSO = CreateObject("Scripting.FileSystemObject")

'Verify the prvided path is not empty
If strPath <> "" Then 'Fixes endless recursion in some instances when at lowest directory

'verify for the provided folder heirarchy in the file system and create if not exists
If Not objFSO.FolderExists(objFSO.GetParentFolderName(strPath)) then Call createtemp(objFSO.GetParentFolderName(strPath),"FOLDER")


'Verify the last node is a folder or file
If UCase(strFSOType) = "FOLDER" Then
objFSO.CreateFolder(strPath)
ElseIf UCase(strFSOType) = "FILE" Then

'If the file is already exists delete it and create new one
If objFSO.FileExists(strPath) Then
objFSO.DeleteFile strPath,True
End If

objFSO.CreateTextFile(strPath)
Exit Sub
End If
End If

Set objFso = Nothing
End Sub


Please provide me your comments

Friday, July 11, 2008

White Papers and Presentations On Test Automation

Hey,

Here is a large collection of Presentations and White Papers on test automation.

Its very rare to find these many articles at one place.

Papers and Presentations

Saturday, July 5, 2008

Friday, July 4, 2008