0

この問題をできる限り単純化しました。以下のコードを「test.linq」ファイルにカット アンド ペーストして、LinqPad にロードできます。現状では、このコードを LinqPad で実行すると、動作することが示されます。意図はtabPage1、UI オートメーション フレームワークを使用して、AutomationId を持つペインを見つけることです。

作業中の行をコメントアウトして、破線を入れます。現在、タブ ページが見つかりません... 唯一の違いは、タブ ページがTextプロパティで宣言されていることです。

障害が自動化プロバイダーにあることを示している可能性のある一連のブログを見つけましたが、ソースを逆コンパイルしたところ、これが事実であることがわかりませんが、ベースはハンドラーを実装しており、実際にはそうではありませんそれがどこにつながるかを確認してください。TabControlTabControlControlWM_GETOBJECT

何か案は?

<Query Kind="Statements">
  <Reference>&lt;RuntimeDirectory&gt;\WPF\UIAutomationClient.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\wpf\UIAutomationProvider.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\wpf\UIAutomationTypes.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\Accessibility.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\wpf\WindowsBase.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\System.Windows.Forms.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\System.Security.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\System.Configuration.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\System.Deployment.dll</Reference>
  <Reference>&lt;RuntimeDirectory&gt;\System.Runtime.Serialization.Formatters.Soap.dll</Reference>
  <Namespace>System.Windows.Automation</Namespace>
  <Namespace>System.Windows.Forms</Namespace>
</Query>

var tabControl = new TabControl();
tabControl.Name = "tabControl";

// Broken
//tabControl.TabPages.Add(new TabPage() { Name = "tabPage1", Text = "First Tab" });

// Working
tabControl.TabPages.Add(new TabPage() { Name = "tabPage1" });

var form = new Form() { Name = "Form1" };
form.Controls.Add(tabControl);
form.Show();

var desktop = AutomationElement.RootElement;
var frmTest = desktop.FindFirst(TreeScope.Children, new PropertyCondition(AutomationElement.AutomationIdProperty, "Form1"));
var tabPage1 = frmTest.FindFirst(TreeScope.Descendants, new PropertyCondition(AutomationElement.AutomationIdProperty, "tabPage1"));
tabPage1.Dump("tabPage1");
4

0 に答える 0