Forum Discussion

gskerman's avatar
gskerman
New Contributor
15 years ago

How do I force a list item collection to update

Hi,



I'm trying to check a list item for a state change. The item has parameters therefore waitproperty will not work, so I am using a while loop to check that the item state has changed.



However, testcomplete appears to cache the list object and is not detecting that the program has changed the property.



object.refresh(); is throwing an exception, and refreshing the parent list object is not updating the children. Am I missing something here?



function checkDraft()

{

  var lst = Aliases["enDesign"]["MainForm"]["ToolStripContainer1"]["ToolStripContentPanel"]["DockPanel1"]["DockWindow"]["DockPane"]["PCList"]["SplitContainer1"]["SplitterPanel"]["fstLstPC"];

  var lstItem = lst.Items["Item"](0)["RowObject"];

 

  var StopWatchObj = HISUtils["StopWatch"];

  StopWatchObj["Start"]();      

  while (StopWatchObj["Split"]() < 30000) {

      if (lstItem["ReferenceLink"]["OleValue"] != '') {

        KeywordTests["Test1"]["Variables"]["CheckDraft"] = true;

        Log.message(VarToStr(lstItem["ReferenceLink"]["OleValue"]));

        return;

      }

      Log.message(VarToStr(lstItem["ReferenceLink"]["OleValue"]));

      lst.refresh(); // lst object is not refreshing

      delay(500);

  }

  StopWatchObj["Stop"]();

  KeywordTests["Test1"]["Variables"]["CheckDraft"] = false;

  return;

}


3 Replies

  • What are the details of the exception? Are you sure that your lst variable is valid? Your example code doesn't show any check on the Exists property, and if it doesn't exist then that would explain the exception.
  • gskerman's avatar
    gskerman
    New Contributor
    The item "exists" as its always visible on the form. I'm doing most of the interaction with keyword tests.....
  • Hi,



    You should refresh the target object (call its Refresh method) before accessing its properties.