Forum Discussion

nimishbhuta's avatar
nimishbhuta
Frequent Contributor
6 years ago

Descriptive Programming with Regular Expression

Hello, 

 

I have gone through different post related to descriptive programming in TestComplete but not found any appropriate answer to implement this. 

 

My requirement about Descriptive programming is as follows : 

 

I am writing custom subroutine for clicking a button on any page as I don't want to use standard method of TestComplete.

    This subroutine will click on the button irrespective of any web application it is not defined for any webpage, 

 For ex : In UFT, I can write Browser("name:=.*").Page("title:=.*").WebButton("name:=.*").Click

From the above example, I can click on any button on any web page, so it is not binded with any application or object repository. 

 

".*" in the code refer Regular Expression which does not relate to any specific object.

 

I would like to have similar thing in TestComplete, I am not interested in creating object from the application and then passing to my subroutine. 

 

Let me know how can it be done with the example. 

 

Regards,

 

Nimish

 

 

       

         

13 Replies

  • shankar_r's avatar
    shankar_r
    Community Hero

    I think it is possible, you can create dummy objects in the NameMapping and modify them in-order to use it as descriptive way.

     

    Like below,

    • nimishbhuta's avatar
      nimishbhuta
      Frequent Contributor

      Hello Shankar, 

       

      Thanks for your reply. I am not sure why we need to create a dummy object instead why can't we use  the mapped or named object hierarchy and use regular expression to achieve the desired result. 

       

      Also,creating the dummy objects and working on it will be additional task and time consuming. I require a good solution on this.

       

      Apart from this, I was evaluation the option to pass the object to the function ClickButton but that is also not working. 

       

      I tried to create the object as Set obj= Aliases.browser.page.button and pass obj in to the ClickButton Sub routine with a statement to click the object but that is also not working. I tried using the map object : Set obj=Sys.browser.page.button but that is also not working. 

       

      Right now, I am clueless on how to create custom sub routines for basic task such as click button, set the text box value etc. 

       

      Regards,

       

      Nimish

      • shankar_r's avatar
        shankar_r
        Community Hero

        I guess, you want your descriptive programming without having any NameMapping predefined.

         

        I personally would not recommend to go without NameMapping since you can not achieve 100% without NameMapping.

         

        Also, TestComplete provide massive options in the NameMapping which ease our automation.

         

         

         

  • I  also stopped to use NameMapping. I replaced the name mapping by a custom solution with the "Find"- method. If you write your method in a clever way you can also use something like a conditional mode and everything else. I hab the same problem. On one testcase I get all elements from the Gui and then I make some interactions with them. It's much easier without name mapping

    • AlexKaras's avatar
      AlexKaras
      Champion Level 3

      Hi,

       

      The final decision for every case depends on the tested application.

      Assuming that the tested application was created with the testability in mind (and this is less than often nowadays), then, usually, the bast approach is a combination of Aliases and .FindXXX(). The peculiarity here is that Aliases must be carefully created in advance, but not automatically during recording. This approach usually provides best balance of code maintainability and performance.

      Pure Aliasing usually can be implemented for simple static applications only.

      Pure .FindXXX() approach might lack performance and be less visually clear, but, depending on the tested application, it may be the only way of controls' identification, unfortunately.

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        That's why we run a blend of the two...  A large part of our AUT is static so Mapping the objects ahead of time takes less code and, therefore, less code maintenance. It gives us better performance (less interpretive code to execute and less overhead in the "find" logic) and gives us the added benefit of cached object identities.  However, there are some dynamic portions to our applications so, in those cases, we use the "Find" methods on a parent object that is, itself, mapped... best of both worlds.

    • nimishbhuta's avatar
      nimishbhuta
      Frequent Contributor

      Hello, 

       

      Can you please provide with a sample example using find and conditional mode,so that I get an idea how to implement it?

       

      Regards,

       

      Nimish