Forum Discussion

Test56's avatar
Test56
Contributor
11 years ago

Retrieving CSS property

Hello, I am using TC 9.3 version. I need to retrieve the web objects CSS properties. I am trying to retrieve it as a property of the web object, e.g. "aqObject.GetPropertyValue(webObject, pr...
  • dganov's avatar
    11 years ago
    There is sample code here: http://support.smartbear.com/viewarticle/62849/, but there is element variable missing in the IE 7-8 code path, so the correct code should be like that:



    Function getStyle(element, styleProp)

      Dim document, style

      Set document = element.ownerDocument



      If aqObject.IsSupported(document, "defaultView") Then

        ' Internet Explorer 9+, Firefox, Chrome, Safari, Opera

        Set style = document.defaultView.getComputedStyle(element, "")

        getStyle = style.getPropertyValue(styleProp)

      Else

        ' Internet Explorer 7 - 8

        getStyle = element.currentStyle.getPropertyValue(styleProp)

      End If

    End Function



    When calling it you should not use "style." in styleProp parameter, just "fontSize" or some other property name.