Forum Discussion

korsar01's avatar
korsar01
Occasional Contributor
14 years ago

WaitWPFObject doesn't work

Hi!


There is WPF TreeView and some buttons. When I push the button "Refresh" - all elements update in TreeView. And after that TestComplete cannot see this elements:


main_folder=Aliases.iexplore.IEFrame.FrameTab.tabpage.ShellDocObjectView.DocObject_Top_Class.pageHttpOisplus64AppProjectsSmar.RootBrowserWindow.MainWindow.Canvas.OpenSaveDialog.Grid.gv.mainGrid.WPFObject("Grid", "", 1).WPFObject("GroupBox", "Tree", 1).WPFObject("Grid", "", 1).WPFObject("tvQueryTree").WPFObject("TreeViewItem", "", 1).WPFObject("editBox");


//main_folder - it's an element in TreeView

refreshf=Aliases.iexplore.IEFrame.FrameTab.tabpage.ShellDocObjectView.DocObject_Top_Class.pageHttpOisplus64AppProjectsSmar.RootBrowserWindow.MainWindow.Canvas.OpenSaveDialog.Grid.gv.mainGrid.WPFObject("Grid", "", 1).WPFObject("GroupBox", "Tree", 1).WPFObject("Grid", "", 1).WPFObject("StackPanel", "", 1).WPFObject("Button", "", 4).WPFObject("StackPanel", "", 1).WPFObject("AutoGreyableImage", "", 1); // it's the button, outside TreeView


refreshf.Click(); //click the button Refresh



if (main_folder.WaitWPFObject("EditBox","*",-1,2000).Exists)

Log.Message("Ok"); //this line never executes


main_folder.Click(); // Error! TestComplete doesn't see the object, but TestComplete can see all buttons.


But when next I write this again (just copy the line (main_folder) above):


main_folder=Aliases.iexplore.IEFrame.FrameTab.tabpage.ShellDocObjectView.DocObject_Top_Class.pageHttpOisplus64AppProjectsSmar.RootBrowserWindow.MainWindow.Canvas.OpenSaveDialog.Grid.gv.mainGrid.WPFObject("Grid", "", 1).WPFObject("GroupBox", "Tree", 1).WPFObject("Grid", "", 1).WPFObject("tvQueryTree").WPFObject("TreeViewItem", "", 1).WPFObject("editBox");


refreshf.Click();


main_folder=Aliases.iexplore.IEFrame.FrameTab.tabpage.ShellDocObjectView.DocObject_Top_Class.pageHttpOisplus64AppProjectsSmar.RootBrowserWindow.MainWindow.Canvas.OpenSaveDialog.Grid.gv.mainGrid.WPFObject("Grid", "", 1).WPFObject("GroupBox", "Tree", 1).WPFObject("Grid", "", 1).WPFObject("tvQueryTree").WPFObject("TreeViewItem", "", 1).WPFObject("editBox");


main_folder.Click(); //it works


 TestComplete can see the object.


It seems to me that redefining the variable is something like Wait... function, because appeared the window that is waiting for the object (main_folder) .


How to solve this issue?



.NET 4.0, WPF, IE 8.0, Windows XP


  • Hi Semyon,





    This is expected behavior. You assign an object reference to a variable. When the object is recreated, the reference stored in the variable becomes invalid, and you cannot use it anymore. You have to get a reference to a new instance of the object in this case.





    You can use the Name Mapping feature in order to access objects by their mapped names. Since mapped names get object references automatically, the reference will be updated automatically as well.