Search code examples
vbscriptqtphp-uft

UFT / QTP : unable to access Object.CurrentStyle in Firefox


I am using the below code for fetching the font size of a "link" on IE.

Browser("BB").Page("PP").Link("link").Object.CurrentStyle.fontSize

However, if I use the same code on FireFox, QTP/UFT throws error:

object required "Object.CurrentStyle".

After alot of research and exploration I found that for FireFox it is not Object.CurrentStyle, but it is Object.Style which is an inbuilt function in QTP, and used below code

Browser("BB").Page("PP").Link("link").Object.style.fontSize

but I'm not fetching the results for the firefox


Solution

  • `TestObject.Object.currentStyle.fontSize` 
    

    will work only on IE not on FireFox, we may get the option to use "Style" in place of "currentStyle" for FireFox but that doesn't work properly. Also the FontSize is read as "FontSize" in IE and "font-size" in Firefox

    To retrieve the required information form the application on Firefox

    set FXObj= Browser("title:=Test_2").Page("title:=Test_2").Link("text:=link")
    
    Set webElem = FXObj.Object
    Set compStyle=Browser("title:=Test_2").Page("title:=Test_2").Object.defaultView.getComputedStyle(webElem, "")
    
    fntsize = CompStyle.getPropertyValue("font-size")
    Print fntsize