如何运行白棋+ Teamcity(Winforms 应用程序)
我正在尝试运行 UI 测试(使用白色编写)。当我使用 NUnitConsole 运行它们时,一切正常。当我尝试使用 TeamCity 运行它们时,出现以下异常 Test(s) failed。 White.Core.UIItems.UIActionException:等待 5000 毫秒后,在进程 4132 中找不到标题为 Form1 的窗口。可能出了什么问题?我该怎么做才能让测试通过?
I'm trying to run UI-tests (written using white). When I run them using NUnitConsole everything works fine. When I try to run them using TeamCity I get the following exception Test(s) failed. White.Core.UIItems.UIActionException : Couldn't find window with title Form1 in process 4132, after waiting for 5000 ms
. What might be wrong? What could I do to make the test pass?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
不仅需要将构建代理设置为与桌面交互,而且还必须显示桌面才能使 UI 自动化正常工作 - 桌面不能被锁定,屏幕保护程序也不能运行。你的代理在无头机器上吗?如果您使用 RDP 连接到代理来检查情况,则当您关闭 RDP 时,它会锁定桌面。在这种情况下,自动化将会失败。不要使用 RDP,而是使用 VNC 查看器登录到盒子,而不是 RDP,因为关闭桌面时 VNC 不会锁定桌面。
另一个需要考虑的问题是网络访问。如果您将 TC 代理作为可以访问桌面的服务运行,那么它将在无法访问网络共享等的服务帐户下运行...如果这是一个问题,那么您将无法运行 TC代理作为服务,而是需要使用域用户登录并启动 agent.bat 文件来启动代理。
Not only does the build agent need to be set to interact with the desktop, but the desktop must be displayed in order for UI automation to work - desktop cannot be locked and screen saver must not be running. Is your agent on a headless machine? If you are using RDP to connect to the agent to check on things, when you close RDP, it locks the desktop. In this case, the automation will fail. Instead of using RDP, use a VNC viewer to log on to the box, rather than RDP, as VNC will not lock the desktop when you close it.
Another issue to consider is network access. If you are running TC agent as a service with access to desktop, then it will be running under service account which will not have access to network shares, etc... If this is a probelm, then you will not be able to run TC agent as a service, and will instead need to logon with a domain user and kick off the agent.bat file to start the agent.
花了很多时间解决这个问题。
主要步骤:
TeamCityBuildAgentfolder\bin
并使用start
参数启动agent.bat
文件如果您所做的一切正确,您应该能够在 TeamCity 的“代理”菜单中看到您的构建代理处于活动状态。
您还可以自动启动 TeamCity 代理(在选定用户登录时):
自动用户登录。更多说明此处
在任务计划程序中创建任务,该任务将在用户登录时启动构建代理管理权限(具有最高权限)
确保自动登录的用户拥有所有必要的权限(运行脚本、执行文件操作等)
重要!
Spent a lot of time solving this issue.
Main steps:
TeamCityBuildAgentfolder\bin
and launchagent.bat
file withstart
argumentIf you done everything right you should be able to see your build agent active in TeamCity's "Agents" menu.
You can also automate TeamCity agent launch (at selected user's logon):
Automate user's logon. More instructions here
Create task in Task Scheduler which will launch build agent at user's logon with administrative rights (with highest privileges)
Make sure that the user who will logon automatically has all neccessary permissions (run the scripts, perform file operations etc.)
IMPORTANT!
您可能必须使 Teamcity 构建代理与桌面交互。
运行->服务.msc ->选择TeamCity Build代理并右键单击->属性->登录选项卡 ->选中“允许服务与桌面交互”
编辑:
如果这不起作用,请停止代理服务,转到构建代理文件夹(c:\ teamcity \ buildagent \ bin?)并发出
agent.bat start 然后触发测试。
You probably have to make the Teamcity build agent interact with desktop.
Run -> services.msc -> Select TeamCity Build agent and right click -> Properties -> Log On tab -> Check "Allow service to interact with desktop"
Edit:
If that doesn't work, stop the agent service, go to Build Agent folder ( c:\teamcity\buildagent\bin ? ) and issue
agent.bat start
and then trigger the tests.建议运行 UI 测试虚拟机。
似乎是最可靠的解决方案。
There is recommendation to run the UI tests on virtual machines.
Seems as most reliable solution.