2012-04-12 24 views
0

UIMap.cs(UIMap.Designer.csではなく)に手書きのコード化コントロールを追加したいと思います。例えばコード化されたコントロールをUIMap(コード化UIテスト)に追加

、ときに私の記録:writing in a texBox、私はUIMap.Designer.csに次のコードを取得する:

public class Recorded_Writing_In_forRecordParams 
{ 
    public string UIForRecordEditText = "forRecord"; 
} 

public class UIMainWindowWindow : WpfWindow 
{ 
    public UIMainWindowWindow() 
    { 
     this.SearchProperties[WpfWindow.PropertyNames.Name] = "MainWindow"; 
     this.SearchProperties.Add(new PropertyExpression(WpfWindow.PropertyNames.ClassName, "HwndWrapper", PropertyExpressionOperator.Contains)); 
     this.WindowTitles.Add("MainWindow"); 
    } 

    public WpfEdit UIForRecordEdit 
    { 
     get 
     { 
      if ((this.mUIForRecordEdit == null)) 
      { 
       this.mUIForRecordEdit = new WpfEdit(this); 
       this.mUIForRecordEdit.SearchProperties[WpfEdit.PropertyNames.AutomationId] = "forRecord"; 
       this.mUIForRecordEdit.WindowTitles.Add("MainWindow"); 
      } 

      return this.mUIForRecordEdit; 
     } 
    } 

    private WpfEdit mUIForRecordEdit; 
} 

は、私は私のCodedUITestでこのコントロールを使用します。 UIMap.csTextBoxをコードで検索したり、TestMethodで検索する方法はありますか?どちらが最善の方法ですか?

+0

あなたがしたいことを理解しているかわかりません。なぜコード内のテキストボックスのUIMapを検索するのですか?または、アプリケーションで特定の値のテキストボックスを検索したいですか? – stoj

答えて

1

答えてくれてありがとう、私は次のように自分で自分の問題を解決:

UIMap.cs

public partial class TestLittleAppUIMap 
{ 
    private MyWindow mMyWindow; 
    public MyWindow MMyWindow 
    { 
     get 
     { 
      if (this.mMyWindow == null) 
      { 
       this.mMyWindow = new MyWindow(); 
      } 
      return this.mMyWindow; 
     } 
    } 
} 

public class MyWindow : WpfWindow 
{ 
    private WpfEdit mWpfEdit; 

    public MyWindow() 
    { 
     this.SearchProperties[WpfWindow.PropertyNames.Name] = "MainWindow"; 
     this.SearchProperties.Add(new PropertyExpression(WpfWindow.PropertyNames.ClassName, "HwndWrapper", PropertyExpressionOperator.Contains)); 
     this.WindowTitles.Add("MainWindow"); 
    } 

    public WpfEdit MWpfEdit 
    { 
     get 
     { 
      if ((this.mWpfEdit == null)) 
      { 
       this.mWpfEdit = new WpfEdit(this); 
       #region Search Criteria 
       this.mWpfEdit.SearchProperties[WpfEdit.PropertyNames.AutomationId] = "forOwn"; 
       this.mWpfEdit.WindowTitles.Add("MainWindow"); 
       #endregion 
      } 
      return this.mWpfEdit; 
     } 
    } 

CodedUIテスト

[TestMethod] 
public void TestLittleAppOwnMap() 
{ 
    this.UIMap.MMyWindow.MWpfEdit.DrawHighlight(); 
    Playback.Wait(2500); 
} 

それほぼデザイナークラスのコピーです。 Playback.Waitだけのハイライトを示すために、短い時間を待つ

[TestMethod] 
public void TestLittleAppOwn() 
{ 
    WpfWindow w = new WpfWindow(); 
    w.SearchProperties[WpfWindow.PropertyNames.Name] = "MainWindow"; 
    w.SearchProperties.Add(new PropertyExpression(WpfWindow.PropertyNames.ClassName, "HwndWrapper", PropertyExpressionOperator.Contains)); 
    w.DrawHighlight(); 

    WpfEdit e = new WpfEdit(w); 
    e.SearchProperties[WpfEdit.PropertyNames.AutomationId] = "forOwn"; 
    e.SetProperty("Text","myText"); 
    e.DrawHighlight(); 
    Playback.Wait(2500); 
} 

:あなたはこのように行くことができるTestMethodで直接検索するための

関連する問題