运行 UI SeleniumRC 测试作为 CI 流程的一部分

发布于 2024-08-07 11:22:15 字数 423 浏览 1 评论 0原文

我正在尝试为 QA 部门设置 CI 环境。他们使用 SeleniumRC 在 IE 和 FF 浏览器中运行 UI 测试来测试一些 Web 应用程序。我成功地将其配置为作为 Windows 服务运行,如所述 此处。但是,当我运行测试时它挂起。我可以在进程列表中看到 Selenium 服务生成的 iexplore.exe 进程,但没有任何反应。没有出现浏览器窗口,Windows 事件日志中没有条目。我做了很多谷歌搜索,据我了解问题是与桌面的交互。我尝试在设置了“允许服务与桌面交互”复选框的系统帐户下以及在具有本地管理员权限的常规用户帐户下运行该服务。所以我的问题是这是否可能?

I'm trying to setup CI environment for QA department. They use SeleniumRC to run UI tests in IE and FF browsers to test some web application. I had a success configuring it to run as a windows service as described here. However when i run the test it hangs. I can see iexplore.exe process spawned by Selenium service in the process list but nothing more happens. No browser window appears, no entries in the windows event log. I did a lot of googling and as fas as i understand the problem is interaction with desktop. I tried to run the service under SYSTEM account with "Allow service to interact with desktop" check-box set as well as under a regular user account with local admin permissions. So my question is if it's possible at all?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(3

洋洋洒洒 2024-08-14 11:22:15

在我们的组织中,我们有一个持续集成服务器(Cruise Control)运行构建,包括 Selenium RC 测试。 CI 服务器作为 Windows 服务运行(在 MS Windows 2003 Server 上),Selenium 测试只是测试套件的一部分。

这是一个非常简单的设置,坦率地说,我认为没有理由放弃它。目前,在我们的设置中,Selenium 服务器(和客户端)是直接从测试启动的(但是我们过去将 Selenium 作为单独的服务)。

在 Java 代码中(实际上是所有 Web 测试的超类),我们会执行以下操作:

// to start the server
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.set(...)  // set the serverHost and port
...
SeleniumServer server = new SeleniumServer(config);
server.start();

// and then to start the client
Selenium selenium = new DefaultSelenium(serverHost, port, "*firefox", "http://www.google.com");
selenium.start();
selenium.open("http://www.google.com");

// now the browser should be visible for you (if you run it locally, not as a service)

因此,我建议您尝试以下操作(无论您使用什么语言):

  1. 尝试仅从独立运行 Selenium 服务器和客户端应用。浏览器应显示为一个窗口。根据您的需要(浏览器类型等)调整设置。

  2. 尝试将代码合并到您的测试框架(xUnit 或其他框架)中。手动运行它们。结果应该是相同的。

  3. 然后您可以尝试从持续集成中运行测试。将 CI 服务器作为服务运行并让它构建您的项目。浏览器将不可见,但这不是运行测试所必需的,不是吗?

笔记:
如果你想窥探Selenium在做什么,我相信在UNIX机器上会更容易。您可以将测试指向使用您选择的 X 服务器 DISPLAY - 连接到某个监视器的假服务器或真服务器。

In our organization we have a continuous integration server (Cruise Control) running the build including Selenium RC tests. The CI server is run as a Windows service (on MS Windows 2003 Server) and Selenium tests are just part of the test suite.

That is quite a straightforward setup and frankly I see no reasons for giving up with it. Currently in our setup the Selenium server (and client) is started directly from the tests (however we used to have Selenium as a separate service).

In Java code (actually in the super class of all web tests) we do something like:

// to start the server
RemoteControlConfiguration config = new RemoteControlConfiguration();
config.set(...)  // set the serverHost and port
...
SeleniumServer server = new SeleniumServer(config);
server.start();

// and then to start the client
Selenium selenium = new DefaultSelenium(serverHost, port, "*firefox", "http://www.google.com");
selenium.start();
selenium.open("http://www.google.com");

// now the browser should be visible for you (if you run it locally, not as a service)

So I would suggest you trying the following (whatever language you are using):

  1. Try to run the Selenium server and client from just a standalone application. The browser should show up as a window. Adjust the settings to your needs (browser type, etc.).

  2. Try to incorporate the code within your test framework (xUnit or whatever). Run them manually. The result should be the same.

  3. Then you can try to have the tests run from the continuous-integration. Run the CI server as a service and let it build your project. The browser wouldn't be visible, but that's not required for the tests to be run, isn't it?

NOTE:
if you wanted to peep what Selenium is doing, I believe it would be easier on UNIX machine. You could point the tests to use the X-server DISPLAY of your choice - a fake one or a true one connected to some monitor.

空名 2024-08-14 11:22:15

我对将任何东西作为应该与桌面应用程序交互的 Windows 服务运行持怀疑态度。 Windows 服务在自己的沙箱中运行;它们不应该与用户的桌面或其应用程序交互。为此,需要付出特殊的努力来与服务进行通信,因此,如果可能的话,我认为也会运行某种桌面客户端,充当浏览器和 Windows 服务之间的联络人。

不过,我不能告诉你这行不通,因为如果人们在博客上谈论它,这显然是可能的。

顺便问一下,为什么它需要作为 Windows 服务运行? Selenium 就是这样设置自动化的,还是可以在没有 Windows 服务的情况下做到这一点?因为我认为这将是两点之间的最短距离。

I'm skeptical about running anything as a windows service that is supposed to interact with a desktop application. Windows services run in their own sandbox; they're not supposed to interact with a user's desktop or its applications. To do so requires special efforts to communicate with the service, so if it is possible at all, I would think there would be some kind of desktop client running as well, acting as a liaison between the browser and the windows service.

I can't tell you it won't work, though, because it is obviously possible if people are blogging about it.

Why does it need to run as a Windows service, by the way? Is that how Selenium has set up their automation, or can you do it without the Windows service? Because I think that would be the shortest distance between two points.

半葬歌 2024-08-14 11:22:15

我的建议是拥有一台专用机器(或虚拟机)来运行 Selenium RC。根据我的经验,最好让 Selenium 以交互方式运行,而不是在无头模式下运行。

My recommendation would be to have a dedicated machine (or virtual machine) for running Selenium RC. In my experience it's best to let Selenium run interactively rather than in a headless mode.

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