Forum Discussion

eykxas's avatar
eykxas
Regular Contributor
2 years ago

Testcomplete is slow to performs basics operations.

Hi everyone !

 

I have an annoying issue with TC since the last update. (15.47.4.7 x64).

Basics operations like Click(), obj.Text = "some string" etc... take a long time to execute. About 3 to 4 seconds.

 

For example I have a very simple login page.

 

it's just a td/tr with some elements (two input, one button)
Searching accross this dom, is really fast for TC. Nearly instantaneous.

this is the code (javascript) : 

in this code almost all lines are executing fast except : input1.Text = login, input2.Text =  password and button.Click().
Before the update (I don't remember the version, maybe 15.41) this code took less than a second to execute, now it take 8 seconds in the best case.

 

 

function login(login = Project.Variables.login, password = Project.Variables.password){
  
  var page = Aliases.browser.pageLogin;   
 
  var input1 = page.Find("ObjectIdentifier", "input_1", 7, false);
  var input2 = page.Find("ObjectIdentifier", "input_2", 7, false);
  var button = page.Find("ObjectType","SubmitButton", 7, false);

  if(input1.Exists){
    input1.Text = login;
  }else{
    Log.Error("input1 not found");
    return false;
  }
  
  if(input2.Exists){
    input2.Text = password;
  }else{
    Log.Error("input2 not found");
    return false;
  }
  
  if(button.Exists){
    button.Click();
    Log.Message("Connection ok");
    return true;
  }else{
    Log.Error("button not found");
    return false;
  }
}

 

 

 
I don't understand why the operations is so long. Thx.

  • Hi,

    after some investigations, I finally found the problem and resolved it. It was the NameMapping.
    To optimize the search of objects in our app, we created a custom NameMapping and organized the Aliases in a hierarchical way. So in script, we can do this :

     

    var obj = Aliases.browser.app.containerOne.subContainerTwo;

     

    and use this object as a starting point for the Find and FindAll method. This, indeed, speed up the script wihout increasing the number of searching level. But it has a huge impact on some operations of TC and in the object browser too.

    To resolve this, I deleted all the objects in the NameMapping, and replace it with a custom method "getContainer" using a Map() inside. Basically, it do the same thing for our project.

    Instead of Aliases, now we have : var obj = getContainer(string); and the method return an object by its xpath.

  • eykxas's avatar
    eykxas
    Regular Contributor

    with the simplified code. Wich has no refresh and full "TC" standard method, it's the same thing.

     

    And look, I attach the "full" code (with refresh) and my workaround. And surprisingly it works fine.

     

     

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I really can't see anything wrong, and I don't understand why the simplified_code struggles to set the Text. Whereas, it can Find the object quickly.

     

    If you were to use SetText() method or set the property wText, will that make any difference in your simplified_code?

  • eykxas's avatar
    eykxas
    Regular Contributor

    Same thing with SetText() or wText. I thought it could be the browser (I'm using Edge) but it's the same behavior with chrome or firefox.

  • eykxas's avatar
    eykxas
    Regular Contributor

    Hi,

    after some investigations, I finally found the problem and resolved it. It was the NameMapping.
    To optimize the search of objects in our app, we created a custom NameMapping and organized the Aliases in a hierarchical way. So in script, we can do this :

     

    var obj = Aliases.browser.app.containerOne.subContainerTwo;

     

    and use this object as a starting point for the Find and FindAll method. This, indeed, speed up the script wihout increasing the number of searching level. But it has a huge impact on some operations of TC and in the object browser too.

    To resolve this, I deleted all the objects in the NameMapping, and replace it with a custom method "getContainer" using a Map() inside. Basically, it do the same thing for our project.

    Instead of Aliases, now we have : var obj = getContainer(string); and the method return an object by its xpath.

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't quite understand this. What was the purpose of creating a custom name mapping? So you are no longer using Aliases?

    • eykxas's avatar
      eykxas
      Regular Contributor

      Sorry my explanation is not very clear. Before we have this :

       

      All of these objects was mapped with xpath (one or two). And it is this quantity of objects which slowed down TC. (94 objects mapped in total)

      Now, I have only one object in the NameMapping (the main container of the web page) and all the sub-container are retrieved from scripts and no more from the NameMapping.

      So no Aliases except the first one (Aliases.browser.page defined with the URL).

  • rraghvani's avatar
    rraghvani
    Champion Level 3

    I don't have that many alias names in my list, but it's organised like so

    But my mapped object list is large, but I don't use XPath.

     

    I guess if it works, then that's great.

  • eykxas's avatar
    eykxas
    Regular Contributor

    I don't know what exactly cause TC to struggle, but removing these mapped objects resolve all my issues.