Get a ListView

Aug 7, 2008 at 2:32 PM
I've tried to search a row in a ListView and edit the value of a cell,using the following code:

ListView gridview = mainWindow.Get<Core.UIItems.ListView>(SearchCriteria.ByText("mainWindow1"))
ListViewRows row = gridview.Rows;

Assert.IsNotNull(row[0].Cells[0].Text);
row[0].Cells[0].DoubleClick();

keyB.HoldKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL);
keyB.Enter("A");
keyB.LeaveKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.CONTROL);
keyB.PressSpecialKey(Core.WindowsAPI.KeyboardInput.SpecialKeys.DELETE);
keyB.Enter("testValue");


I also tried :
                Table gridview1 = mainWindow.Get<Table>(SearchCriteria.ByText("mainWindow1"));
                TableRows row = gridview1.Rows;

But, when I ran my test , I got the next error:

Section: Bricks in SectionGroup: Bricks is not configured in Configuration file
Using RecheckDurationInMilliseconds=100 for Bricks/Bricks
TestCase 'SimpleTest.XXX.Edit'
failed: System.NullReferenceException : Object reference not set to an instance of an object.
    C:\WpfApplication2\Tests\Class1.cs(53,0): at SimpleTest.XXX.Edit()

Could you please help me with this issue, I would really appreciate it.
Coordinator
Aug 7, 2008 at 5:05 PM
Looks like this line is wrong.
Table gridview1 = mainWindow.Get<Table>(SearchCriteria.ByText("mainWindow1"));

instead of "mainWindow1" you need to specify the automationId of the table.

Can you send me the complete stacktrace?
Aug 8, 2008 at 10:56 AM
I changed the line:

 Table gridview1 = mainWindow.Get<Table>("listView1");
 But I got the same error:
                         Section: Bricks in SectionGroup: Bricks is not configured in Configuration file
                        Using RecheckDurationInMilliseconds=100 for Bricks/Bricks
                        TestCase 'SimpleTest.XXX.Edit'
                        failed: System.NullReferenceException : Object reference not set to an instance of an object.


the stacktrace is :  at SimpleTest.XXX.Edit() in C:\WpfApplication2\Tests\Class1.cs:line 48
it turns out from <TableRows row = radgridview1.Rows; > ,that <gridview1> is null.

I also tried changing:
 ListView gridview = mainWindow.Get<ListView>("listView1");
 ListViewRows row = gridview.Rows;

When it reaches the next line,the following exception is thrown:

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

Stack trace:  at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
                    at System.ThrowHelper.ThrowArgumentOutOfRangeException()
                    at System.Collections.Generic.List`1.get_Item(Int32 index)
                    at SimpleTest.XXX.Edit() in C:\Work\projects\WpfApplication2\WpfApplication2\Tests\Class1.cs:line 55

What am I doing wrong?


Aug 8, 2008 at 11:29 AM
Sorry, the error "Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index is caused by mistake in my code."

This code actually gets the ListView:
 ListView gridview = mainWindow.Get<ListView>("listView1");
 ListViewRows row = gridview.Rows;

Thank you