C# 如何访问ClassName RichTextBox的文本
我试图在我的窗口中找到一个文档,该文档有一个富文本框,其中包含使用TestStack White的文本,并提取该文本 我曾尝试使用UIItem标签和文本框,但White似乎无法在测试期间找到该对象。可以使用通用UIItem找到该对象,但我希望能够访问它所包含的文本 我正在像这样实施它:C# 如何访问ClassName RichTextBox的文本,c#,richtextbox,ui-automation,white-framework,teststack,C#,Richtextbox,Ui Automation,White Framework,Teststack,我试图在我的窗口中找到一个文档,该文档有一个富文本框,其中包含使用TestStack White的文本,并提取该文本 我曾尝试使用UIItem标签和文本框,但White似乎无法在测试期间找到该对象。可以使用通用UIItem找到该对象,但我希望能够访问它所包含的文本 我正在像这样实施它: public[不确定]MyRichTextBox { get{return Window.get(SearchCriteria.ByClassName(“RichTextBox”);} } 我想说: Assert
public[不确定]MyRichTextBox
{
get{return Window.get(SearchCriteria.ByClassName(“RichTextBox”);}
}
我想说:
Assert.That(MyRichTextBox.Text.Equals(x))代码>
但是,如果我将其标记为标签或文本框,它将找不到我要查找的内容,并且如果我将其声明为UIItem,则无法访问.Text。您想使用文本框的类型。然后可以使用BulkText访问RichEditBox中的文本
首先打开窗口:
TestStack.White.UIItems.WindowItems.Window _mainWindow;
app = TestStack.White.Application.Launch(startInfo);
_mainWindow = app.GetWindow("MyDialog");
然后找到richEditBox:
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_;
}
}
以下是使用白色文本方法的代码注释:
// 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.
您想使用文本框的类型。然后可以使用BulkText访问RichEditBox中的文本
首先打开窗口:
TestStack.White.UIItems.WindowItems.Window _mainWindow;
app = TestStack.White.Application.Launch(startInfo);
_mainWindow = app.GetWindow("MyDialog");
然后找到richEditBox:
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_;
}
}
以下是使用白色文本方法的代码注释:
// 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.