簡體   English   中英

如何在C#+ TestStack.White中的ControlType.Text中驗證文本?

[英]How can I verify text in ControlType.Text in C# + TestStack.White?

如何使用C#+ TestStack.White驗證ControlType.Text中的文本? 我只是試圖驗證錯誤消息是正確的並且包含正確的短語。

我嘗試了不同的解決方案:

  1. TextBox errorTextBox = MainWindow.Get(“ txbError”); Assert.AreEqual(“用戶名或密碼無效”,errorTextBox.Text);

  2. TextBox errorTextBox = MainWindow.Get(SearchCriteria.ByText(“用戶名或密碼無效”)); Assert.AreEqual(errorTextBox.Text,“用戶名或密碼無效”);

和別的...

在VS中總是出現錯誤:

TestStack.White.AutomationException:無法獲取ControlType = edit,Name =用戶名或密碼無效

屏幕截圖

//Your login logic
...
var textBoxes = mainWindow.GetMultiple(SearchCriteria.ByControlType(ControlType.Text));
foreach(Label textBox in textBoxes)
{
 if(textBox.Id.Contains("txbError"))
 {
  var actualError = textBox.Name.ToString();
  Assert.AreEqual(actualError, "Expected Error message");
 }
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM