ui-automationwhite-framework

Cannot click ListViewCell with null value


The tests I am developing access the DataGrid cells the following way:

 window.Get<ListView>(gridName).Rows.First().Cells.First()

Then clicking a cell with UIItem.Click() method works fine, unless the cell is bound to a null value. In such a case, I get an exception:

Failed to click on ListViewCell. AutomationId:, Name:, ControlType:text, FrameworkId:WPF, bounds empty

Which makes sense, as apparently, an AutomationElement related to that cell is a TextBlock of 0 boundaries. Is there some possible workaround to click such a cell so the tests work?


Solution

  • What seems to be a good enough workaround is the following:

    this.window.Mouse.Location = Point.Subtract(cellToClick.ClickablePoint, new Vector(12, 6)); 
    this.window.Mouse.Click(this.window.Mouse.Location);
    

    So I just set the mouse location using property TestStack.White.UIItems.Mouse so it is situated right above the cell, then click.