Skip to content
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

Need to get selection from disabled ComboBox #674

Open
jeffhuckins opened this issue Jul 20, 2023 · 0 comments
Open

Need to get selection from disabled ComboBox #674

jeffhuckins opened this issue Jul 20, 2023 · 0 comments

Comments

@jeffhuckins
Copy link

I have a need to get the selection from a disabled WPF .NET 6 ComboBox in order to verify the selection even though it is disabled. I found a way for a WinForms .NET Framework ComboBox, but the solution doesn't work for a .NET 6 WPF ComboBox.

What worked for the WinForms .NET Framework ComboBox was:
` AutomationElement comboElement = window.GetElement(SearchCriteria.ByControlType(ControlType.ComboBox).AndAutomationId(automationId));

        if (comboElement != null)
        {
            LogEntry.Debug(log, $"Found ComboBox AutomationElement");
            comboElement.TryGetCurrentPattern(ValuePattern.Pattern, out object oPattern);

            if (oPattern != null)
            {
                text = (oPattern as ValuePattern).Current.Value;
                LogEntry.Debug(log, $"Combo Selected Text = \"{text}\"");
            }
            else
            {
                LogEntry.Debug(log, "Failed to get ComboBox ValuePattern");
            }
        }

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant