如何运行白棋+ Teamcity(Winforms 应用程序)

发布于 2024-11-05 13:23:53 字数 214 浏览 0 评论 0原文

我正在尝试运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

看透却不说透 2024-11-12 13:23:53

不仅需要将构建代理设置为与桌面交互,而且还必须显示桌面才能使 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.

无戏配角 2024-11-12 13:23:53

花了很多时间解决这个问题。

主要步骤:

  1. 您需要单独的计算机,并在其上安装 teamcity 构建代理。电脑应该有显示器和鼠标。
  2. 代理不应作为 Windows 服务启动和运行(如果需要,请将其禁用)。
  3. 您应该从 .bat 文件启动 TeamCity 构建代理(以管理员身份)。为此,请转至 TeamCityBuildAgentfolder\bin 并使用 start 参数启动 agent.bat 文件
  4. 在一定时间后禁用计算机的屏幕睡眠/锁定。您的测试将需要桌面来进行 UI 操作。

如果您所做的一切正确,您应该能够在 TeamCity 的“代理”菜单中看到您的构建代理处于活动状态。

您还可以自动启动 TeamCity 代理(在选定用户登录时):

  1. 自动用户登录。更多说明此处

  2. 在任务计划程序中创建任务,该任务将在用户登录时启动构建代理管理权限(具有最高权限)

  3. 确保自动登录的用户拥有所有必要的权限(运行脚本、执行文件操作等)

重要!

  • 运行 UI以这种方式进行测试是一个潜在的安全漏洞,因此请确保未经授权的人员无法访问运行此测试的计算机。
  • 请记住,为了运行 UI 测试,计算机不应锁定或处于睡眠模式。

Spent a lot of time solving this issue.

Main steps:

  1. You need separate computer with teamcity build agend installed on it. Computer should have monitor and mouse.
  2. The agent SHOULD NOT be launched and run as a Windows service (disable it if needed).
  3. You should launch TeamCity build agent from .bat file (as administrator). To do this go to TeamCityBuildAgentfolder\bin and launch agent.bat file with start argument
  4. Disable computer's screen sleep/lock after certain period of time. Your tests will require desktop for UI manipulations.

If 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):

  1. Automate user's logon. More instructions here

  2. Create task in Task Scheduler which will launch build agent at user's logon with administrative rights (with highest privileges)

  3. Make sure that the user who will logon automatically has all neccessary permissions (run the scripts, perform file operations etc.)

IMPORTANT!

  • Running UI tests in such way is a potential security hole so make sure that the non-authorized people have no acccess to computer that runs this tests.
  • Remember that for running your UI test the computer SHOULD NOT be locked or be in sleep mode.
入画浅相思 2024-11-12 13:23:53

您可能必须使 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.

往昔成烟 2024-11-12 13:23:53

建议运行 UI 测试虚拟机。

似乎是最可靠的解决方案。

There is recommendation to run the UI tests on virtual machines.

Seems as most reliable solution.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文