【发布时间】:2026-01-03 13:20:02
【问题描述】:
我的计算机上的每个 UI 测试都有一个问题:Test method threw exception: Couldn't find window with title Calculator。当然,窗口是存在的,它的名字是“计算器”(通过检查检查)。其他 UI 元素也是如此。
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TestStack.White;
using TestStack.White.Factory;
using TestStack.White.UIItems;
namespace UnitTestProject3
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
using (var application = Application.Launch("Calc.exe"))
{
var calculator = application.GetWindow("Calculator", InitializeOption.NoCache);
// do something with the application
var b7 = calculator.Get<Button>(TestStack.White.UIItems.Finders.SearchCriteria.ByText("7"));
b7.Click();
application.Close();
}
}
}
}
会是什么?
提前感谢您的帮助。
【问题讨论】:
-
我是新人,没有足够的声望上传图片,没关系
-
不,这样不行。 以文本形式与我们分享您的代码。阅读我发布的链接。
-
不是代码的问题,是我给你加的)
-
在您运行测试之前应用程序是否已经启动?或者其他一些有“计算器”窗口的应用程序?
标签: c# visual-studio testing automated-tests ui-testing