Forum Discussion

biloge81's avatar
biloge81
New Contributor
6 months ago

Access to custom property

Hi at all,

I have a problem with testing a custom widget.

I have a custom property inside it that is public exposed and visible inside browser webtools, but is not reachable in Testcomplete code.

It seems that only standard HTML properties of my widget are available.

Have you any idea about it?

 

example :

widget property :  myWidget.enableTA = true ;

selecting in devtools <myWidget> tag and in console : $0.enableTA -> true

 

7 Replies

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    "More details" such as a screenshot of the control? Source code from DevTools, and example of getting enableTA property value.

  • biloge81's avatar
    biloge81
    New Contributor

    I have an HTML widget that extends HTMLElement and implements a custom interface

     

    I would add this :

    The following code:

    myWidget.WaitProperty("enableTA", true, 2000);

    doesn't return any object (not-existent COMObject).

     

    And the following code:

    aqObject.findProperties(myWidget,"*")

    doesn't return the enableTA property.



  • simonaferrara's avatar
    simonaferrara
    Frequent Contributor

    Hi  Marsha_R  and rraghvani ,

    I'm the tester colleague of biloge81  😉 

    I try to give you more information about the issue.

     

    We are working on a Web site, not on a Desktop app, so the previously linked documentation is not useful for this issue. 

    The component that I've to test is based on canvas technology.

     

    Developers have added a boolean property (called "enabled") within a DOM element (the "trend" one that I highlight you within below screenshot, partially obfuscated for company security reasons):


    I can reach this property within the browser console through the following code:

    but I'm not able to read this property from the automatic test code, for example this code returns a Not-existent COMObject:
    let trendEnabled = trend.WaitProperty("trendControl.enabled", true, 2000);
    where "trend" correctly contains the DOM object corresponding to the "trend" html tag.

    I've also asked to change the implementation by exponing this property outside the "trendControl" object, by using the $0.enabledTA mode as the example shown within the initial post, but it still not visible.

    What could be the reason? What can I suggest to developers to make it possible to have this property visible from the test automation point of view?

    The strange thing is that I've already a couple of cases on other components (also canvas ones) in which I can access to its properties without issues.

    Have you got a suggestion basing on these information?

    Thanks and regards,   
    Simona

     

     

  • simonaferrara's avatar
    simonaferrara
    Frequent Contributor

    Hi,

     

    unfortunately the last suggestion still doesn't work. The enabled returns an empty object.

     

    In the meanwhile, I've tried also to extract through the TA both the innerHTML and outerHTML and search for the property within them, but still without success.

     

    Could there be a characteristic of the page implementation that prevent this property to be visible for the TA? 

    Or do you have any other suggestion?

     

    Thanks!

    Simona

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    You can get the DOM via page.contentDocument.Script.eval(), but you'll have to play around with the input to get what you need. 

     

    I can't find a similar website to show you a proper example.

     

    Are you using Shadow DOM?