Forum Discussion

sebastian_novy's avatar
12 years ago

Scripting iterated actions for ListViewItems

Hello,



I am having a problem while working with WPF ListViewItems.
In the programm I am testing several ListView controls are used.
Each can hold a variable number of ListViewItems containing other controls.
Test data are read from an external Excel file and should be entered into these controls.

These data also determine how many ListViewItems are to be created.



When I record a script with the repeated creation of ListviewItems and the input of data then I see in the playback that only the first ListViewItem is repeatedly filled with the data.

The other items are created but as soon as data is entered the focus leaps back to the first item where it is entered.




When I write something like this:



for(var i=0; i&#060listView.wItemCount; i++)

{

listViewItem = listView.wItem(i);

comboBox = listViewItem.ContentPresenter3.cb_TableArrivalReport;

comboBox.ClickItem(0);

}



there is always the error that this object doesn't exist or is null.

Strangely the following lines work in the script before the loop:



listViewItem = listView.ListViewItem;

...

comboBox = listViewItem.ContentPresenter3.cb_TableArrivalReport;

comboBox.ClickItem(0);



I have taken a look at the NameMapping and there "ListViewItem" and "ListViewItem2" are listed as children for the ListView.

In addition only the first item has all 4 contentPresenters (containers for other controls) listed as children, while the second is missing all except one.



My Question:

How do I access or focus the controls in the last created ListViewItem of the corresponding Listview so data can be entered?




Thanks in advance.

1 Reply


  • Hi Sebastian,


     


    This behavior may require some investigation. I suggest that you contact the TestComplete Support team. I would appreciate it if you sent them a video that demonstrates the problem. To record a video, you can use Jing - a free screen capture tool.