-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Controls Do not get distinct automation ID's #2166
Comments
@jublin it seems you should give your controls a |
@punker76 I have done that.
With Name being defined as x:Name= or Name=, I get The updown buttons also have no name. The overall control does not appear as a focus element. |
@jublin what automatic tool is this? |
@punker76 This is the "VisualUIAVerify" tool from the windows SDK |
@jublin ok, thx, i will take a look after releasing v1.2.0 |
This also applies to the Back/down buttons on MetroWindow Flyouts. The automation ID is seen as "nav" for each one. Getting a back button by automationID in testing may not return the intended button for the flyout. |
@punker76 I'm working on a solution for this |
I´m working on a new implementation based on AutomationPeers. Should be available soon. |
@punker76, @petvetbr any news on this issue (after 7 years ;-))? public class AutomationNumericUpDown : NumericUpDown
{
protected override AutomationPeer OnCreateAutomationPeer()
{
if (GenericAutomationPeer.IsEnabled)
{
var ap = new AutomationNumericUpDownAutomationPeer(this);
return ap;
}
return base.OnCreateAutomationPeer();
}
private sealed class AutomationNumericUpDownAutomationPeer : FrameworkElementAutomationPeer, IValueProvider
{
private NumericUpDown _owner;
public AutomationNumericUpDownAutomationPeer(NumericUpDown owner)
: base(owner)
{
_owner = owner;
var automationContext = owner.GetValue(AutomationHelpers.AutomationContextProperty) as string;
if (!string.IsNullOrWhiteSpace(automationContext) && owner.Template != null)
{
var txt = owner.Template.FindName("PART_TextBox", owner) as TextBox;
if (txt != null)
{
txt.SetValue(AutomationProperties.AutomationIdProperty, $"txt_{automationContext}");
}
var up = owner.Template.FindName("PART_NumericUp", owner) as ButtonBase;
if (up != null)
{
up.SetValue(AutomationProperties.AutomationIdProperty, $"btn_{automationContext}.Up");
}
var down = owner.Template.FindName("PART_NumericDown", owner) as ButtonBase;
if (down != null)
{
down.SetValue(AutomationProperties.AutomationIdProperty, $"btn_{automationContext}.Down");
}
}
}
public override object GetPattern(PatternInterface patternInterface)
{
if (patternInterface == PatternInterface.Value)
{
return this;
}
return base.GetPattern(patternInterface);
}
#region IValueProvider
bool IValueProvider.IsReadOnly
{
get { return false; }
}
string IValueProvider.Value
{
get { return _owner.Value?.ToString(); }
}
void IValueProvider.SetValue(string value)
{
if(double.TryParse(value, out double num))
{
_owner.Value = num;
}
else
{
_owner.Value = null;
}
}
#endregion IValueProvider
protected override string GetLocalizedControlTypeCore() => "numeric up down";
protected override string GetClassNameCore() => "NumericUpDown";
protected override AutomationControlType GetAutomationControlTypeCore() => AutomationControlType.Custom;
}
} |
@lightwalker01 No news on this front. I was not able to implement this, sorry. |
Thank You @lightwalker01 for your post of workaround. This library is really terrible in terms of automation. But your workaround really works There is also a bug #4454 posted for a really long while which blocks the whole process of test automation, and it is not fixed. I find it unfortunate that we need to implement workarounds. |
@noubar this is a totally free time project and the devs work on things they need. So things are done when they are done. Contribtions are welcome if you want to speed things up. Thanks for your understanding. |
#2166 automatiopeer for numericupdown
When using controls such as NumericUpDown, I am unable to get a unique automationID from the control. They all show up as this: The name is being set in the Xaml. Unfortunately I cannot really give a code snippet.
The problem is my group is trying to test a window with multiple NumericUpDowns and other controls with this same issue. Automating a test becomes impossible to do with this.
The text was updated successfully, but these errors were encountered: