System.Windows.Forms.ListView Check box is not recognized by UIA verrify

470 Views Asked by At

I am quite new to UI Automation and UI Verify tool.

In our application, we are using System.Windows.Forms.ListView with CheckBoxes property set to true.

The CheckBoxes property allows you to display a check box next to each item in the list. This enables your application to display a list of items (and subitems if the View property is set to View.Details)

So far individual row and all values in each row is identified. Only checkbox is not recognized by UI verify.


namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent()

        listView1.CheckBoxes = true;
        listView1.View = View.Details;
        listView1.Columns.Add("Automation");
        listView1.Columns.Add("result");
        listView1.Items.Add(new ListViewItem(new string[] { "1", "Pass" }));
    }

}

Output: Both values "1" and "pass" are recognized by UIA verify. However the check box is not recognized.


Has anybody else experience similar behavior? and if so is there any fix for this?

Much appreciated for all the help.

Regards Hari Hara

2

There are 2 best solutions below

0
On

Are you using "hover" mode? Try checking the pane structure near the checkbox items in the left pane of UIA verifier window.

1
On

From what I can see the whole list item supports the toggle pattern.

enter image description here

So you should be able to use the toggle pattern of the row control itself.

    /// <summary>
    /// Toggles anything that supports the toggle pattern
    /// </summary>
    /// <param name="aeElement">Automation element to toggle</param>
    public void Toggle(AutomationElement aeElement)
    {
            TogglePattern tpToggle = (TogglePattern)aeElement.GetCurrentPattern(TogglePattern.Pattern);
            tpToggle.Toggle();
    }