While some of a WebElement’s style properties are available via it’s Test-Object properties (e.g. its height, visibility etc.), a lot of its visual styling is left unknown to QTP. This can be overcome via its Runtime .CurrentStyle property.
For example, this WebElement is the welcome header of AdvancedQTP’s main page:
'Grabe the WebElement
Set oWebElement = Browser("AdvancedQTP - the resource")._
Page("AdvancedQTP - the resource")._
WebElement("Welcome to AdvancedQTP")
'Grabe the WebElement’s Runtime-Object’s CurrentStyle object
Set oStyle = oWebElement.Object.CurrentStyle
As you can see by the debug screenshot, the CurrentStyle object holds many many useful propertis:
So for example, we can find out the object’s direction (ltr = left-to-right), font-family (Ariel), color (HTML code=#06c), indentation (0pt), borders, and other useful properties.
'This will print the WebElement’s text-color HTML code.
Msgbox oStyle.Color
Posted in Web


Yaron Assa




April 14th, 2008 at 3:56 pm
hi
i have tried this example, but i am not able to get the objects after setting oWebElement..
does anyone explain me in detail for this..
thank you
kinjal shah
April 20th, 2008 at 7:27 pm
I have created the similar QTP tutorial on QTP - get font size/color, background color and other attributes.
It seems, getting of WebElement’s styles is a popular topic :)
May 30th, 2008 at 12:24 pm
wonderfull solution that helped me to found these properties. But Object property is supported by IE only not by Mozilla firefox, do you have any idea how to get those
July 31st, 2008 at 7:45 pm
Can anybody tell how to get the font size for the Swflabel in QTP using Vbscript
Thanks in advance,
Selvi
October 1st, 2008 at 4:05 pm
How do you get all that information in the Debug screen? I’m using the standard QTP debug window and the only thing I can see is oStyle = , but you cannot expand it and see which its attributes are…
Can you please let me know how you achieved it? that would be really useful :)
Many thanks!