Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts
Tips to be followed for a successful test Automation
Labels:
Automation Concepts,
Automation framework
VBScript Code - Function to convert CSV file into excel and viceversa in QTP using VBScript
Labels:
qtp Scripts,
QTP Tutorials,
VBScript
We at times are required to convert excel files into csv to read as flat files and sometime require to convert a csv file into excel file to use excel features on the data.
Below function shows how to convert an csv file into excel file and vice versa. We can also convert to other formats based on constants
Here constant value 23 is used to create a csv file and constant -4143 to save a file as xls file.Once the destination file is created, we can delete the source file as shown below. In case of any issue in understanding the code, please add in comment section
Call func_ConversionCSVExcel("E:\Test.csv", "E:\Test_converted.xls", "csvtoexcel")
Public Function func_ConversionCSVExcel(strSrcFile, strDestFile, Conversion)
on error resume next
Set objExcel = CreateObject("Excel.application")
set objExcelBook = objExcel.Workbooks.Open(strSrcFile)
objExcel.application.visible=false
objExcel.application.displayalerts=false
If(Conversion = "ExceltoCSV") Then
objExcelBook.SaveAs strDestFile, 23
else
objExcel.ActiveWorkbook.SaveAs strDestFile,-4143
End If
objExcel.Application.Quit
objExcel.Quit
Set objExcel = Nothing
set objExcelBook = Nothing
Set objFSO = CreateObject("scripting.FileSystemObject")
objFSO.DeleteFile(strSrcFile)
Set objFSO =nothing
End Function
How to load multiple function libraries at runtime from Quality Center in QTP
Labels:
Advanced QTP,
qtp Scripts,
Test Scripts
This post explains how to load multiple libraries at runtime from Quality Center in a QTP test. As the test size grows, it is better to associate or load function library at runtime with all the tests.
Note we should associate an initialization library with each of the test and then perform following work in the initialization library.
- Load all the function library with the test
- Load the shared object Repository with the test.
- Remove the local object repository with the test to avoid object conflict
- Load the environment variables to be used across test
- Close all instances of application.
- Providing the reporter configuration for the test. e.g: allowing reporting in QTP Reporter on scenario of error only
In the current post, we will focus only on how to load multiple libraries at runtime from Quality Center or local folder.
In the case of using local folder structure , the path [QualityCenter] Subject\Project_Name \...... changes to c:\QTP_Automation/......
Const strLibraryNames = "[QualityCenter] Subject\Project_Name\QTP\Libraries\Library1.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library2.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library3.vbs>[QualityCenter] Subject\Project_Name\QTP\Libraries\Library4.vbs"
callfunc_LoadFunctionLibrary(strLibraryNames)
Function func_LoadFunctionLibrary(strLibraryName)
''Load multiple Library Files seperated by '>'
collLibrary = split(strLibraryName, ">")
''Now collLibrary is an array with each element in array storing the path of library
For i = 0 to ubound(collLibrary)
LoadFunctionLibrary collLibrary(i)
Next
End Function
Subscribe to:
Posts (Atom)