Forum Discussion

vthomeschoolmom's avatar
vthomeschoolmom
Super Contributor
5 years ago
Solved

Extend TestComplete for a different clicky event

Consider this line of code.

 

Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry.Click();

 

I have an object in name mapping that I click. Loverly. 

 

There are many instances that want I really need to have done is

 

Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry.scrollIntoView();
Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry.Click();

 

Pretty easy. But what I want to do, if possible, is extend TestComplete to provide a method, something like NavigatorClick that performs scroll then click since I am going to be using this a LOT. But more to the point, the team I am coaching is going to be using it a LOT. And yah know. Learning new stuff is fun. Also, I have found scrollIntoView sometimes doe snot work. Of course, if I find a mechanism that works better, I want to be able to change it once rather than go everywhere I used this method.

 

Is this even in the realm of the possible? If so, can someone direct me to the place to start? Thanks.

  • Not quite as such, no.  You can't do 

    Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry.NavigatorClick()

     

    What you CAN do is

     

    NavigatorClick(Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry)

     

    Look up ScriptExtensions.  You can create a runtime object that would encapsulate that method that would be universally available to all projects without needing to do any kind of shared file libraries.

3 Replies

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    It is not possible to add/remove methods/properties to/from built-in TestComplete objects.

     

    Possible options:

    a) Create common public function and use it;

    b) Create Script Extension with the same function;

    c) Create a Custom Plugin with the same function again.

     

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Not quite as such, no.  You can't do 

    Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry.NavigatorClick()

     

    What you CAN do is

     

    NavigatorClick(Aliases.browser.pageMain.wndWindowHeader.panMenuContent.mnuTicketInquiry)

     

    Look up ScriptExtensions.  You can create a runtime object that would encapsulate that method that would be universally available to all projects without needing to do any kind of shared file libraries.