Forum Discussion

Piyush_77's avatar
Piyush_77
Occasional Contributor
7 years ago

Want to block the Error When Tree nodes are not exapandable

Hello,

 

I have code in Java script. I want to expand tree node using Expand  command. In which i have  10 items to expand. out of 10  2 are not expandable.  every time when i run the code for that 2 items Test log automatically generate the error ' The tree node cannot be expanded or collapsed.' which i dont want. I ant to stop or block that error. what can i do??

 

for (i = 0; i < objectChildTreeViewHelp["Items"]["Count"]; i++)
{

my_array[i] = objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
stringText="|SoMachine Motion Overview|SoMachine Motion Overview|Releasenotes|"+stringReleaseNotesChildTextName+ "|" +objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
objectTreeViewHelp["ExpandItem"](stringText)
Log["Checkpoint"]("Success: "+ my_array[i]+ " RealeaseNote Expanded Successfully")


}

  • Another way of doing this and getting to know what are all clicked, etc.

     

          for (i = 0; i < objectChildTreeViewHelp["Items"]["Count"]; i++)
          {
    
                my_array[i] = objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
                stringText="|SoMachine Motion Overview|SoMachine Motion Overview|Releasenotes|"+stringReleaseNotesChildTextName+ "|" +objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
                var stringTextArr = stringText.split("|");
                var currentItem = objectTreeViewHelp.Items("SoMachine Motion Overview");
                var menuToClick = "|SoMachine Motion Overview";
                
                for(ml = 2 ; ml < stringTextArr.length ; ml++){
                      var currentChildMenu = stringTextArr[ml];
                      menuToClick += "|" + currentChildMenu;
                      currentItem = objectTreeViewHelp.Items(menuToClick);
                      if (!strictEqual(currentItem.Items, null)){
                            objectTreeViewHelp["ExpendItem"](menuToClick);
                      }else{
                            objectTreeViewHelp["ClickItem"](menuToClick);     
                      }
                }
                
                Log["Checkpoint"]("Success: "+ my_array[i]+ " RealeaseNote Expanded Successfully")
    
    
          }
  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    Option 1 (quick and dirty)

    var logState = Log.Enabled;

    Log.Enabled = false;

    <ExpandItem>

    Log.Enabled = logState;

     

    Option 2 (most correct):

    var isExpandable = <isItemExpandable>; // exact implementation depends on the given item

    if (isExpandable)

      <ExpandItem>

    else

      <LogSomethingIfNeeded>

     

    Option 3 (a kind of workaround if option 2 cannot be implemented):

    Utilize OnLogError event and event handler and lock error logging if the error is caused by the attempt to expand non-expandable item.

     

  • shankar_r's avatar
    shankar_r
    Community Hero

    Another way of doing this and getting to know what are all clicked, etc.

     

          for (i = 0; i < objectChildTreeViewHelp["Items"]["Count"]; i++)
          {
    
                my_array[i] = objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
                stringText="|SoMachine Motion Overview|SoMachine Motion Overview|Releasenotes|"+stringReleaseNotesChildTextName+ "|" +objectChildTreeViewHelp["Items"]["Item"](i)["Text"]
                var stringTextArr = stringText.split("|");
                var currentItem = objectTreeViewHelp.Items("SoMachine Motion Overview");
                var menuToClick = "|SoMachine Motion Overview";
                
                for(ml = 2 ; ml < stringTextArr.length ; ml++){
                      var currentChildMenu = stringTextArr[ml];
                      menuToClick += "|" + currentChildMenu;
                      currentItem = objectTreeViewHelp.Items(menuToClick);
                      if (!strictEqual(currentItem.Items, null)){
                            objectTreeViewHelp["ExpendItem"](menuToClick);
                      }else{
                            objectTreeViewHelp["ClickItem"](menuToClick);     
                      }
                }
                
                Log["Checkpoint"]("Success: "+ my_array[i]+ " RealeaseNote Expanded Successfully")
    
    
          }