【问题标题】:Selenium-PHPUnit, Selenium GridSelenium-PHPUnit,Selenium Grid
【发布时间】:2012-07-23 00:08:32
【问题描述】:

在发布这个之前,我在这个网站和谷歌上检查了很多,以找出我的问题。 我正在测试我的 Web 应用程序,该应用程序主要使用 Symfony2 框架在 PHP 中编码。

我正在使用 Selenium 进行功能测试。目前我想做的就是使用 Selenium Grid 在我的本地机器上并行运行我的功能测试。我所做的是在 Selenium IDE 上记录测试并以 phpunit 格式导出测试用例。我尝试使用 selenium 网格,但我的 phpunit 测试仍在按顺序运行。

我做了什么:

1) java -jar selenium-server-standalone-2.24.1.jar -role hub

2) java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444/grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2"

3) 蚂蚁

在我的 build.xml 中有一个 phpunit 目标:

<target name="phpunit" description="Run unit tests">
  <exec executable="phpunit" failonerror="true"/>
</target>

在我的 phpunit.xml 中存在这部分代码:

<testsuites>
    <testsuite name="LoginSuite">
       <file suffix="Test.php">../../src/Tests/FunctionalTests/LoginSuite_testLoginTest.php</file>
    </testsuite>
</testsuites>

我的 LoginSuite_testLoginTest.php 看起来像这样:

<?php

namespace Tests\FunctionalTests;
use Tests\FunctionalTests\SetUpTest;

class LoginSuite_testLoginTest extends SetUpTest
{
  public function testLogin()
  {
    $this->open("/home");
    $this->click("link=Login");
    $this->type("id=username", "test.user@gmail.com");
    $this->type("id=password", "test");
    $this->click("id=_submit");
    $this->waitForPageToLoad("30000");
  }


  public function testLogin2()
  {
    $this->open("/home");
    $this->click("link=Login");
    $this->type("id=username", "test.user2@gmail.com");
    $this->type("id=password", "test");
    $this->click("id=_submit");
    $this->waitForPageToLoad("30000");
  }
}
?>

在我启动 ant 命令的第三步时,我收到了一个码头错误 500 访问 /selenium-server/driver/ 时出现问题

如果不是这样做:

java -jar selenium-server-standalone-2.24.1.jar -role node -hub http://localhost:4444  /grid/register -browser "browserName=firefox,maxInstances=2,maxSession=2"

我在没有 -browser 信息的情况下执行相同的命令,它会启动我的测试但不是并行...,太奇怪了。

我看到要并行启动 phpunit 测试,我们必须创建自己的脚本来执行它。那么在这种情况下我是否需要硒网格?我很迷茫。感谢您的帮助。

【问题讨论】:

    标签: selenium automation phpunit automated-tests selenium-grid


    【解决方案1】:

    phpunit 命令行https://github.com/siivonen/parallel-phpunit 有一个并行包装器,因此您无需编写它。您需要在某处运行 Selenium Hub(连接一些节点)。然后您运行指向该位置的测试,Hub 会将调用代理到空闲节点。

    我们使用 parallel-phpunit 和 Selenium Grid,四个节点连接到一个集线器。我们的 CI 在 3 分钟内运行 30 分钟的 Selenium 测试。

    【讨论】:

      【解决方案2】:

      可能存在不同的问题。一种是,在运行预先记录的步骤时,您应该在“浏览器”参数中添加 seleniumProtocol=Selenium,因为默认情况下它将是 webdriver。

      【讨论】:

        猜你喜欢
        • 2013-12-19
        • 1970-01-01
        • 2011-11-02
        • 2011-11-29
        • 2016-07-26
        • 2014-06-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多