Skip to main content

Posts

Convert Image Formats

You could face situations like changing the format of the image file or reduce the file size by changing the formats. Here is the way to get it done in simple way. Function ConvertImage ( strFromFile , strToFile ) Dim oImage , oFileImage , oImageFormats , oFSO , strToExtn Set oFSO = CreateObject ( "Scripting.FileSystemObject" ) Set oImage = DotNetFactory . CreateInstance ( "System.Drawing.Image" ) Set oFileImage = oImage . FromFile ( strFromFile ) Set oImageFormats = DotNetFactory . CreateInstance ( "System.Drawing.Imaging.ImageFormat" , "System.Drawing" , Nothing ) strToExtn = oFSO . GetExtensionName ( strToFile ) Select Case UCase ( Trim ( strToExtn ) ) Case "JPEG" oFileImage . Save strToFile , oImageFormats . Jpeg Case "JPG" oFileImage . Save strToFile , oImageFormats . Jpeg Case "BMP" oFileImage . Save strToFile , oImageFormats . Bmp Case ...

Change IE Browser ZOOM settings

Lot of UI automation testers could have faced this problem as we could change the zoom settings while operating manually for our convenience and forgot to reset to 100%. But our QTP and some other related tools would operate the browser perfectly if browser zoom is 100%. So wee need to change the zoom before start to run the scripts. Its better to have a code snippet in our framework to change this zoom setting right? Here we go... 1. We can simply change the Registry values before Invoking IE Function  ChangeRegistry   Dim  objShell   Set  objShell =  CreateObject ( "WScript.Shell" )  objShell.RegWrite  "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom\ZoomFactor" ,  "100000" ,  "REG_DWORD"   Set  objShell =  Nothing End   Function This option is very useful. But in real time, lot of customers could have restricted write access to windows registry. So we can try othe...

Read, Write Excel - QTP, VbScript

Lot of members are facing some errors whenever trying to connect and read/write values from excel or other databases. Here is some code snippet which will easy the task for you... To Get Data: Function GetData(strFilePath, strSQL)  Dim objConn, objRecord, strConnectionString  Set objConn = CreateObject("ADODB.Connection")  Set objRecord = CreateObject("ADODB.RecordSet")  strConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strFilePath & ";Excel 12.0;HDR=YES;READONLY=1;IMEX=1;"  objConn.Open strConnectionString  objRecord.Open strSQL, objConn  msgbox objRecord(0).Value  objConn.Close End Function Points to take care: 1. Always use readonly=1 to force read-only mode while reading. 2.Use IMEX value based on your requirement. IMEX=1 - It will convert all data types to text and return. IMEX=2 - It will return the data as it is. To Write Data: Function UpdateData(strFilePath, strSQL)  Dim objConn...

QTP - Get multi line data from Excel Cell

Today I am going to write a simple topic on excel and it seems very simple but lot of automation testers in need of this topic. Say I want to have multiple data on a single cell(using ALT+ENTER). This will solve the purpose as well as maintenance easy.  Ok, How to get that data from excel and separate the data which was enterted using ALT+ENTER. Just get the cell data and replace the string for vbLF with "" (Empty String) and you can pass your data. Normally new line indicates vbCRLF (Chr(13) + Chr(10)) but in excel new line char is Char(10) i.e. only vbLF not vbCR or vbCRLF. Hope this will help you guys !!!

QTP - Memory Usage and Others

Lot of guys will face app hanging problem while script execution in QTP. You can always use QTP provided SystemMonitor API to know memory usage by application an you can decide your control mechanisms. SystemMonitor.GetValue("YourApp.exe","Memory Usage (in MB)") In the same way, you can get processor usage, Os details, etc.. If this will give you exact thing, always you can use WMI to get every system information you need.

QTP - Object Identification Types / Ways

In QTP, we can use lot of ways to identify an object. Most of the QTP Test Developers are always using streamlined and static approaches and if object is not identifiable using those approaches, just leaving then as not identifiable. We can try using below ways of handling objects for our purpose before saying NO !!! 1. Store the objects in OR If you are comfortable on using OR and suitable for your project with your designed framework, you can go ahead with OR. a. Add the object in OR, then see what are the properties will make QTP to identify this object uniquely.  b. Remove unwanted properties c. Add unique and required properties d. Assign regular expressions for the required properties which have dynamic values in full or part.Make use of Reg Exp Evaluator to set the RegExp correctly. e. Assign a human understandable, easily classifiable logical name for the object based on type of object, application module or screen, etc. 2. Use Descriptive Programming Here...

QTP - Common error messages

Always I am seeing  many of my friends asking for help if any error occurs while running script in QTP without googling for help. How much troubleshooting you guys are doing will directly reflect your knowledge on the tool. I agree, no one knows each and every error occurs in the software. But we can improve our knowledge by googling and doing workarounds... Whenever the question "How much level you know QTP?" arrows me, always I am comfortable with the answer "below 10%". But after answered, my mind will have an inner thought like, What are the things I have to learn to fulfill the answer I have told because I never used lot of features in QTP. Here I am listing out some of the errors, situations and what might be the original issue things etc. I hope this will give you some ideas to improve your debug ability and to solve your errors. Kindly correct me If I am wrong in any point. Type mismatch: - Mostly doing operations with different data types without doi...