continuous-integration - 运行 UI SeleniumRC 测试作为 CI 过程的一部分

标签 continuous-integration selenium selenium-rc

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

最佳答案

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

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

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

// 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)

所以我建议您尝试以下方法(无论您使用什么语言):
  • 尝试从一个独立的应用程序运行 Selenium 服务器和客户端。浏览器应该显示为一个窗口。根据您的需要调整设置(浏览器类型等)。
  • 尝试将代码合并到您的测试框架(xUnit 或其他)中。手动运行它们。结果应该是一样的。
  • 然后,您可以尝试从持续集成中运行测试。将 CI 服务器作为服务运行并让它构建您的项目。浏览器将不可见,但这不是运行测试所必需的,不是吗?

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

    关于continuous-integration - 运行 UI SeleniumRC 测试作为 CI 过程的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1576526/

    相关文章:

    firefox - centOS、Jenkins、Firefox 和 Selenium GRID -- UnableToCreateProfileException

    java - 如何不使用 x 路径在 selenium webdriver 中选择单选按钮

    testing - Selenium 多次运行相同的方法

    azure-devops - 有没有办法识别在 Azure Devops CI 构建中 checkin 的 TFS 分支?

    git - 在 "git submodule foreach"后添加条件逻辑

    ios - Xcrun 没有嵌入传递的配置文件

    build - Teamcity - 参数化构建

    java - Selenium:选择间接兄弟元素

    session - Selenium 测试 - 跨多个测试运行保留 session

    java - Selenium 测试和 emma 代码覆盖率