How capture image width and Height

uiautomation
studio

#1

Hi,

How to extract size and width of list of Images. Please help


#2

If they are a list of images on a web site, after getting a selector for the image you can use the Get Attribute activity for “height” and “width”.

If they are images on the computer that method doesn’t seem to work, but you could pull up the properties of each image and scrape the Details tab to get the image size.


#3

If you can’t find these, try “outerhtml” or “innerhtml” attribute.

Another way you can try is, if you have each Image as an element and if they are visible on screen:

element.Screenshot.Height.ToString
element.Screenshot.Width.ToString

If Desktop,

System.Drawing.Image.FromFile("path").Height.ToString
System.Drawing.Image.FromFile("path").Width.ToString

#4

Thanks @mwsupra and @vvaidya,

But im get empty value.


#5

Use the UIExplorer on it first then click Property Explorer on the left. That will show you what attributes are available for that image.


#6

Hi ,

I tried with “outerhtml” , but im not geting height and width.


#7

Do you have innerhtml attribute at all? Not 100% sure, but since the image is responsive you may not get the height attribute as it can vary with screen size.

For the sake of it, try find element activity on image and you could do this if Image is clearly visible on screen.

element.Screenshot.Height.ToString
element.Screenshot.Width.ToString


#8

Hi ,

How to and where to use this “element.Screenshot.Height.ToString”. Can you pls provide us an example.


#9

Use it in write line to check the result.


#10
  1. use find element activity and select your image.Make sure image is visible on screen.
  2. output of find element(say element)

3)write line height and width as shown above.

Thanks,

Vinay


#11

Hi,

Its giving me the height of Screenshot. Is there any other way to capture exact size and width. I’ve multiple images in a page.


#12

URL looks from a dell website, share the URL someone might be able to help.


#13

Hi @vvaidya,

When I tried in Get attribute in Open browser activity unable to get height and width, but when use Get attribute directly im getting properties like height and width.