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のラインでサポートされていないパターンをスロー: 私は、次の方法を試してみました。