Forum Discussion

ThomasCasserly's avatar
ThomasCasserly
Frequent Contributor
6 years ago
Solved

Html 5 custom data attribute on Firefox

Hi all, 

 

So this links to my other recent post about HTML 5 custom data attributes. I can now view custom attributes, they appear listed under either the "attributes" or "dataset" object properties, but only when I'm using Chrome.

 

If I use Firefox, the custom data attribute, is not listed under either the "attributes" or "dataset" properties. I can see the custom attribute if I view the text of the OuterHTML property of the object , so I think I'm at the right level in the object tree (I'm viewing the parentelement of the onscreen object)

 

Any ideas on how/if the custom data attribute can appear under either the "attributes" or "dataset" object properties? when using Firefox?

 

Thanks in advance

 

Tom.

  • Hi,

     

    If I got it right, you are trying to inspect custom attributes of some SPAN element accessed via parentElement property of its child.

    The reason you can't see those attributes is that the property returns a native browser object instead of TestComplete extended object. Native browser objects return "raw" attributes and dataset collections, those collections do not list attribute names as properties (see NamedNodeMap and DOMStringMap). For that purpose you need to use TestComplete-specific Parent property instead of the native parentElement (the reason you can successfully use parentElement in Google Chrome is, in fact, an undocumented trait of TestComplete implementation of Chrome support).

    Another important thing is that, most likely, you are using parentElement instead of Parent because your SPAN element is not included in TestComplete object tree and, thus, not accessible via Parent. If so, you can either try not to use the SPAN in your tests/NameMapping at all, or, make this SPAN appear in the object tree by adding text content or role attribute to the SPAN (see Web Elements Included in and Excluded From the Tree Model).

     

    Hope this helps.

10 Replies

  • Hi,

     

    If I got it right, you are trying to inspect custom attributes of some SPAN element accessed via parentElement property of its child.

    The reason you can't see those attributes is that the property returns a native browser object instead of TestComplete extended object. Native browser objects return "raw" attributes and dataset collections, those collections do not list attribute names as properties (see NamedNodeMap and DOMStringMap). For that purpose you need to use TestComplete-specific Parent property instead of the native parentElement (the reason you can successfully use parentElement in Google Chrome is, in fact, an undocumented trait of TestComplete implementation of Chrome support).

    Another important thing is that, most likely, you are using parentElement instead of Parent because your SPAN element is not included in TestComplete object tree and, thus, not accessible via Parent. If so, you can either try not to use the SPAN in your tests/NameMapping at all, or, make this SPAN appear in the object tree by adding text content or role attribute to the SPAN (see Web Elements Included in and Excluded From the Tree Model).

     

    Hope this helps.

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Great reply from Stanislav!

       

      To Community: It looks like that we need to add the "How exactly this web element was obtained?" question to the check-list questionnairie.

       

    • ThomasCasserly's avatar
      ThomasCasserly
      Frequent Contributor

      Ok,

       

      thanks for the reply, I'll check out the article and let our developers know that there might be  a bit more work for them to do ;-)

  • cunderw's avatar
    cunderw
    Community Hero

    Which version of firefox are you using? Seems to be working just fine for me. 

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        Have you made sure you've downloaded the latest Firefox updates for TestComplet?