I want to write a coded UI test like "Some WPF control when some condition should not be visible". How do I assert "is not visible"?
To reproduce the issue:
There's no way to assert that the button is hidden!
Additionally:
I've found the best way to work around the IsVisible
limitation is to use the TryGetClickablePoint(out System.Drawing.Point)
method of the UITestControl object. This method will return a Boolean value. So, for example, if you have a WpfButton:
WpfButton mine = new WpfButton(parent);
mine.SearchProperties["id"] = "id";
Point toString;
bool result = mine.TryGetClickablePoint(out toString);
Assert.IsTrue(result, "My Assertion here.");
That has worked more often than not. To handle collapsed or expanded, though, is there some property of the object that changes based on its state? For example, if the class is class="myobject expanded"
, you could easily assert based on mine.GetProperty("Class").ToString().Contains("expanded");
as a Boolean value.
Try to use GetProperty method:
WpfButton myButton = new WpfButton(); if(myButton.GetProperty("Enabled").Equals(true)) { ... CODE }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.