Forum Discussion

EkremMese1's avatar
EkremMese1
Contributor
5 months ago

Performance Comparison NameMapping vs FindElement

Hello everyone, 

I have came across with a Test Case where I locate the WebElement with 2 different ways. 

One is with NameMapping: 

OCR.Recognize(NameMapping.Sys.browser.pagePersonCreate.inputBoxAgeType).CheckText("*Years*");

 

The other one is with FindElement Method:

OCR.Recognize(Aliases.browser.pagePersonCreate.FindElement("//label[text()='Years']")).CheckText("*Years*");


I realzie that FindElementh Method is working way faster than NameMapping located objects. 

Even TestComplete itself gave me a warning to improve the Test performance when I use NameMapping

I am curious about the opinions and experiences of yourself/

Thanks

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    EkremMese1 wrote:

    I am curious about the opinions and experiences of yourself

    Generally speaking, properly crafted Aliases (that must be used instead of NameMapping) are way more preferable and flexible approach in TestComplete world. The only exception is when one needs to create web tests that must be executed on web farm like BitBar.

    But in real life, ineffective NameMapping (for example, that heavily relies on Extended Find which is turned on by default) may result in worse performance when compared to XPath.

     

    • EkremMese1's avatar
      EkremMese1
      Contributor

      Do you think using NameMapping.... for the WebElements instead of Aliases slows down the testing? 
      Because Aliases is more complicated for me, than NameMapping...

      • rraghvani's avatar
        rraghvani
        Champion Level 3

        How is Aliases more complicated than Name Mapping?

  • eykxas's avatar
    eykxas
    Regular Contributor

    Hi !

    I think, in your case, the best performance is due to the Xpath method and not the Alias. Xpath acts as a pointer to the element. If the webpage's DOM tree is not too complicated, finding elements with XPath is almost instantaneous. 

    (This is why in my project I avoid using NameMapping or Aliases).