[英]How to handle abort window in Coded UI test
我有一個類似下面的場景:
-綠色路徑1)打開表單2)提供文件路徑3)運行進程4)生成輸出5)成功將消息寫入表單上的屏幕,然后6)啟用關閉按鈕。
-通過編碼的UI測試自動化上述工作流程。
-紅色路徑1)打開表單2)提供文件路徑3)運行進程4)不生成輸出5)彈出ABORT窗口(需要在啟用“關閉”按鈕之前將其關閉)6)啟用“關閉”
但是,要解決上述紅色路徑的情況,我無法使用為綠色路徑編寫的自動編碼的UI測試,有沒有辦法在綠色路徑的編碼UI測試中處理ABORT窗口?
謝謝。
[TestMethod]
public void CodedUITestMethod1()
{
//my green path recording.
this.UIMap.GreenPathCode();
//my red path recodring.
this.UIMap.RedPathCode();
}
public void GreenPathCode()
{
#region Variable Declarations
WinEdit uITextBox1Edit = this.UIForm1Window.UITextBox1Window.UITextBox1Edit;
WinButton uIButton1Button = this.UIForm1Window.UIButton1Window.UIButton1Button;
WinButton uIButton2Button = this.UIForm1Window.UIButton2Window.UIButton2Button;
#endregion
// Type '1' in 'textBox1' text box
uITextBox1Edit.Text = this.GreenPathCodeParams.UITextBox1EditText;
// Click 'button1' button
Mouse.Click(uIButton1Button, new Point(21, 10));
// Click 'button2' button
Mouse.Click(uIButton2Button, new Point(35, 8));
}
public void RedPathCode()
{
#region Variable Declarations
WinEdit uITextBox1Edit = this.UIForm1Window.UITextBox1Window.UITextBox1Edit;
WinButton uIButton1Button = this.UIForm1Window.UIButton1Window.UIButton1Button;
WinButton uIAbortButton = this.UIErrorWindow.UIAbortWindow.UIAbortButton;
WinButton uIButton2Button = this.UIForm1Window.UIButton2Window.UIButton2Button;
#endregion
// Type '2' in 'textBox1' text box
uITextBox1Edit.Text = this.RedPathCodeParams.UITextBox1EditText;
// Click 'button1' button
Mouse.Click(uIButton1Button, new Point(35, 10));
// Click '&Abort' button
Mouse.Click(uIAbortButton, new Point(51, 12));
// Click 'button2' button
Mouse.Click(uIButton2Button, new Point(56, 16));
}
您是否嘗試過這樣做? 當然,您必須將代碼移出設計器文件。
[TestMethod]
public void CodedUITestMethod1()
{
this.UIMap.RedPathCodeParams.UITextBox1EditText="1";
this.UIMap.RedAndGreenPath();
this.UIMap.RedPathCodeParams.UITextBox1EditText="2"
this.UIMap.RedAndGreenPath();
}
public void RedAndGreenPaths()
{
#region Variable Declarations
WinEdit uITextBox1Edit = this.UIForm1Window.UITextBox1Window.UITextBox1Edit;
WinButton uIButton1Button = this.UIForm1Window.UIButton1Window.UIButton1Button;
WinButton uIAbortButton = this.UIErrorWindow.UIAbortWindow.UIAbortButton;
WinButton uIButton2Button = this.UIForm1Window.UIButton2Window.UIButton2Button;
#endregion
// Type '2' in 'textBox1' text box
uITextBox1Edit.Text = this.RedPathCodeParams.UITextBox1EditText;
// Click 'button1' button
Mouse.Click(uIButton1Button, new Point(35, 10));
// Click '&Abort' button
if(this.RedPathCodeParams.UITextBox1EditText=="2") //You could also use uIAbortButton.Exists instead
Mouse.Click(uIAbortButton, new Point(51, 12));
// Click 'button2' button
Mouse.Click(uIButton2Button, new Point(56, 16));
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.