Print Page | Close Window

How to check file extensions using QTP

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=7037
Printed Date: 18Jan2025 at 6:05am


Topic: How to check file extensions using QTP
Posted By: Mithi25
Subject: How to check file extensions using QTP
Date Posted: 22Sep2009 at 2:23am

Using QTP, we want to validate whether the particular image on a web page is .jpg, .gif, .bmp or any other extension.

Solution:

  1. We will take the example of Mercury demo application  http://newtours.demoaut.com/ - http://newtours.demoaut.com/image
  2. The image to be checked is shown in red ellipse above.
  3. Now “Object spy” on the object. image
  4. Find the property containing filename. Usually the name of the property would be file name itself. The value for this case is featured_destination.gif.
  5. Put this value into a array using GetTO property.
  6. Now make use of split function with . (dot) as delimiter.
  7. The last value of the array would be your required file extension. Usually the 2nd value inside an array would be the file extension, but in case developer assigns the name as featured.destination.gif [Notice the two dots] then it might create a problem that’s why always take the last value of the array.

Here is the script for the process given above:

Dim filename, arrfile

'Put filename into the array

filename =  Browser("Welcome: Mercury Tours").Page("Welcome: Mercury Tours").Image("Featured Destination:").GetTOProperty("file name")

' Split using "." as delimiter

arrfile = split(filename,".")


-------------
http://www.quick2sms.com - Send Unlimited FREE SMS to Any Mobile Anywhere in INDIA,
Click Here



Print Page | Close Window