2016-09-13 5 views
-1

私は、TestStack Whiteを使用してテキストを含む豊富なテキストボックスを持つウィンドウを探し、そのテキストを抽出しようとしています。ClassName RichTextBoxのテキストにアクセスする方法

私はUIItem Label & TextBoxを使用しようとしましたが、ホワイトはテスト中にオブジェクトを見つけることができないようです。オブジェクトは汎用UIItemを使用して見つけることができますが、保持しているテキストにアクセスできるようにしたいと考えています。

私はそれが好きで実装しています:

public [Unsure] MyRichTextBox { get { return Window.Get<[Unsure]>(SearchCriteria.ByClassName("RichTextBox")); } }

と私は言っできるようにしたいと思います:

Assert.That(MyRichTextBox.Text.Equals(x));

をしかし、それは私は何を見つけることができません私はLabelまたはTextBoxとしてタグ付けするかどうかを探しますが、UIItemを宣言すると.Textへのアクセス権がありません。

答えて

1

TextBoxの種類を使用します。次に、BulkTextを使用してRichEditBox内のテキストにアクセスできます。

まずウィンドウ:ここ

string data = RichEditDocument.BulkText; 

を使用するためのコードのコメントです:

public string _richeditdocument_ID = "rtbDocument"; 
private TextBox _richeditdocument_ = null; 
public TextBox RichEditDocument 
{ 
    get 
    { 
     if (null == _richeditdocument_) 
       _richeditdocument_ = _mainWindow.Get<TextBox>(SearchCriteria.ByAutomationId(_richeditdocument_ID)); 
       return _richeditdocument_; 
    } 
} 

は次に、テキストにアクセスするには、次を使用します。

TestStack.White.UIItems.WindowItems.Window _mainWindow;  
app = TestStack.White.Application.Launch(startInfo); 
_mainWindow = app.GetWindow("MyDialog"); 

はその後richEditBoxを探しますテキスト方式の白:

ここ
// Summary: 
    //  Enters the text in the textbox. The text would be cleared first. This is 
    //  not as good performing as the BulkText method. This does raise all keyboard 
    //  events - that means that your string will consist of letters that match the 
    //  letters of your string but in current input language. 
    public virtual string Text { get; set; } 

BulkTextを使用するためのコメントです:

 // Summary: 
     //  Sets the text in the textbox. The text would be cleared first. This is a 
     //  better performing than the Text method. This doesn't raise all keyboard events. 
     //  The string will be set exactly as it is in your code. 
関連する問題