【问题标题】:TestRunner not running automatically when running Selenium 2.0 HTML Selenese tests using Selenium-Maven Plugin使用 Selenium-Maven 插件运行 Selenium 2.0 HTML Selenese 测试时,TestRunner 不会自动运行
【发布时间】:2011-06-06 22:49:25
【问题描述】:

我正在尝试通过 Selenium Maven 插件(1.1 版)使用 selenese 命令运行一系列 HTML selenium 测试,希望能找到能够在不同浏览器(Chrome、Firefox、Internet)上运行这些测试的解决方案资源管理器,野生动物园)。通过 Maven,我可以通过输入不同的浏览器值作为属性来创建不同的配置文件。我还计划在像 Hudson 这样的持续集成服务器上运行它。

但是,现在,我面临着两难境地。我能够让 FireFox 4 显示 TestRunner,这要归功于这个论坛的一些帮助,方法是让插件使用 Selenium Server 2.0。但是,当浏览器被激活时,TestRunner 只是坐在那里,它不会自动运行套件中的测试。

如果我在 Selenium IDE 中运行测试套件,它运行得非常好,所以我知道测试套件没有问题。我还使用 IE 浏览器选项运行了测试套件,它运行良好,没有任何问题。我还确认降级到 Firefox 3.6 后它会运行,所以我相当肯定这与 Firefox 4 和 Maven Selenium 插件有关。

请在下面查看我的 POM 文件的 sn-p。

....
<properties>
    <selenium.server.version>2.0a7</selenium.server.version>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>selenium-maven-plugin</artifactId>
            <version>1.1</version>
            <configuration>
                <browser>*firefox</browser>
                <suite>src/test/selenium/html/suite.html</suite>
                <startURL>http://localhost:5555/</startURL>
                <port>5555</port>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.seleniumhq.selenium</groupId>
                    <artifactId>selenium-server</artifactId>
                    <version>${selenium.server.version}</version>
                    <exclusions>
                        <!-- prevent ant:ant versus org.apache.ant:ant collision -->
                        <exclusion>
                            <groupId>ant</groupId>
                            <artifactId>ant</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>Run-Selenese-Scripts</id>
                    <phase>integration-test</phase>
                    <goals>
                        <goal>selenese</goal>
                    </goals>
                    <configuration>
                        <port>5555</port>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
....

我使用 Maven 命令 mvn integration-test 运行脚本,正如我之前提到的,它会打开 TestRunner 页面,但测试不会自动运行。它使用的 URL 如下。

chrome://src/content/TestRunner.html?auto=true&multiWindow=false&defaultLogLevel=info&baseUrl=http%3A%2F%2Flocalhost%3A5555%2F&resultsUrl=http://localhost:5555/selenium-server/ postResults&test=http%3A%2F%2Flocalhost%3A5555%2Fselenium-server%2Ftests%2Fsuite.html

我觉得奇怪的是,当我将上面的 URL 更改为下面的 URL 时,它会自动运行测试,这正是我想要的。

http://localhost:5555/selenium-server/core/TestRunner.html?test=..%2Ftests%2Fsuite.html&resultsUrl=http%3A%2F%2Flocalhost:5555%2Fselenium-server%2FpostResults

我的问题是有没有办法让 Maven-Selenium 插件通过使用有效的 URL 为 Firefox 4 自动运行?我需要配置一些设置吗?

如果答案是否定的,那么运行 Selenium HTML 脚本以使它们独立于浏览器运行的最方便的方法是什么。另外,在我们的构建完成并部署代码之后,我能否在持续集成服务器(如 Hudson)上运行这些测试?

非常感谢您,

胡安

【问题讨论】:

    标签: maven-2 maven selenium-rc selenium-webdriver selenium-grid


    【解决方案1】:

    我发现了这个问题。我只是升级到 Selenium Server 2.0b3 工件,它运行顺利。显然,2.0a7 于 2010 年 10 月发布,而 2.0b3 于 2011 年 3 月发布,与 Firefox 4 发布时间相吻合。

    测试现在可以在 firefox 上自动运行。我希望这对遇到同样问题的其他人有所帮助。

    干杯,

    胡安

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      相关资源
      最近更新 更多