问题
I'm trying to write some coded ui tests for a WPF application and have gotten to part of the application that contains a datagrid with collapsing and expanding rows.
I am able to find and interact with controls on the collapsed rows fine using hand-coded tests but haven't had any luck finding any of the controls in the expanded part of the row. Using the crosshairs on such a control shows the item to be under UIItemRow, UIItemCustom (class name Uia.DataGridDetailsPresenter), and then the target control. I'm not sure on how to tell the tests to search to find these controls.
回答1:
Maybe its caused by the vertical virtualization. In any case, try this Snoop
It is a must have for any WPF developer. Most likely in situation when you are traversing through the visual tree.
回答2:
In the UITest file check the Search Properties and Filter Properties, I'm not sure your exact problem but it usually fixes problems with searching for controls.
来源:https://stackoverflow.com/questions/17755252/coded-ui-test-finding-controls-on-expanded-row