You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
I'm getting an empty text for WPF ComboBoxItem when using e.g. SelectedItem.Text. Select(string textToFind) also does not work properly.
The issue is in the Text property getter: for WPF it tries to get the first child and returns its name:
public virtual string Text
{
get
{
if (this.FrameworkType == FrameworkType.Wpf)
{
AutomationElement firstChild = this.Automation.TreeWalkerFactory.GetRawViewWalker().GetFirstChild((AutomationElement) this);
if (firstChild != null)
return firstChild.Properties.Name.Value;
}
return this.FrameworkAutomationElement.Properties.Name.Value;
}
}
But the problem is that the "actual" text element is not the first child. The same implementation is in the ListBoxItem.
To fix this, the getter might be changed to something like:
public virtual string Text
{
get
{
var treeWalker = this.Automation.TreeWalkerFactory.GetRawViewWalker();
var child = treeWalker.GetFirstChild(this);
while (child != null)
{
if (child.ControlType == FlaUI.Core.Definitions.ControlType.Text)
return child.Name;
child = treeWalker.GetNextSibling(child);
}
return this.FrameworkAutomationElement.Properties.Name.Value;
}
}
The text was updated successfully, but these errors were encountered:
Describe the bug
I'm getting an empty text for WPF ComboBoxItem when using e.g.
SelectedItem.Text
.Select(string textToFind)
also does not work properly.The issue is in the
Text
property getter: for WPF it tries to get the first child and returns its name:But the problem is that the "actual" text element is not the first child.
The same implementation is in the
ListBoxItem
.To fix this, the getter might be changed to something like:
The text was updated successfully, but these errors were encountered: