Sponsored Ad

Tuesday, December 22, 2009

How to check file extensions using QTP

Using QTP, they need to validate whether the particular picture on a web page is .jpg, .gif, .bmp or any other extension.

Solution:

  • We will take the example of Mercury demo application

image 

 

  • The image to be checked is shown in red ellipse above.
  • Now “Object spy” on the object.

image

  • Find the property that contains the file name. Normally the name of the property would be the file name itself. The value of this case is featured_destination.gif.
  •  Put this value into a array using GetTO property
  • Now make use of split function with . (dot) as delimiter.
  • The final value of the array would be the file extension. Normally, 2 value within a set would be the file extension, but if a developer uses the name as featured.destination.gif [least three points] then could create a problem so we always have the ultimate value of the matrix.
  • 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,".")

msgbox arrfile(Ubound(arrfile))

    ·

0 comments:

Post a Comment

Sponsored Ad

More Related Articles

Website Update

Followers