【发布时间】:2012-08-14 10:21:16
【问题描述】:
我有一个类似下面的场景:
--绿色路径 1) 打开一个表格 2)给出文件的路径 3)运行进程 4) 生成输出 5) 成功将消息写入表单上的屏幕,然后 6) 关闭按钮启用。
-- 通过 Coded 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));
}
【问题讨论】:
-
简单的问题到目前为止您尝试过什么代码......??
-
我没有尝试过任何 DJ 抱歉根本没有得到任何想法 :(...我正在尝试捕获 sAbort 窗口并尝试使用绿色路径代码中的代码 :( 不幸的是没有任何工作
-
您至少必须编写一些代码,以便其他人可以了解您正在尝试做什么。我们在这里不介意读者
-
抱歉 DJ 添加了代码供您参考,,, 在示例代码中我试图在绿色路径代码功能中添加中止按钮案例,以便在弹出中止按钮窗口时我可以处理那个案子。我计划从数据源发送输入,因此只想为此目的使用一种方法。
-
如果我还不清楚对不起。我会提供更多信息。
标签: c# visual-studio-2010 coded-ui-tests