2
UI 자동화 및 .NET을 사용하여 런타임에 TextBox를 활성화 한 후 TextBox에서 값을 설정하는 방법을 아는 사람이 있습니까?TextBox가 값 패턴에 지원되지 않는 패턴을 던졌습니다.
자세한 내용은 : 처음에는 응용 프로그램을로드하는 동안 TextBox가 비활성화되었습니다. 자동화를 사용하여 확인란을 전환하면 TextBox가 활성화됩니다. 그러나 자동화를 사용하면 액세스 할 수 없습니다.
PropertyCondition parentProcCond = new PropertyCondition(AutomationElement.ProcessIdProperty, processes[0].Id);
Condition chkCondition = new AndCondition(
new PropertyCondition(AutomationElement.IsEnabledProperty, true),
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.CheckBox),
new PropertyCondition(AutomationElement.NameProperty, chkName));
//Find Elements
var parentElement = AutomationElement.RootElement.FindFirst(TreeScope.Children, parentProcCond);
var chkUseMyAccountElement = parentElement.FindFirst(TreeScope.Descendants, chkCondition);
TogglePattern pattern = chkUseMyAccountElement.GetCurrentPattern(TogglePattern.Pattern) as TogglePattern;
ToggleState state = pattern.Current.ToggleState;
if (state == ToggleState.On)
{
pattern.Toggle();
}
Condition txtDomainCondition = new AndCondition(
new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Text),
new PropertyCondition(AutomationElement.NameProperty, txtDomain)
);
var txtConditionElement = parentElement.FindFirst(TreeScope.Descendants, txtDomainCondition);
ValuePattern valuetxtDomain = txtConditionElement.GetCurrentPattern(ValuePattern.Pattern) as ValuePattern;
valuetxtDomain.SetValue("US");
그것은 valuePattern이 라인에서 지원되지 않는 패턴을 던졌습니다 : 나는 다음과 같은 방법을 시도했다.