使用Selenium-Maven插件运行Selenium 2.0 HTML Selenese测试时,TestRunner不会自动运行

时间:2011-06-06 22:49:26

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

我试图通过Selenium Maven插件(版本1.1)使用selenese命令运行一系列HTML selenium测试,希望能够提供一个能够在不同浏览器(Chrome,Firefox,Internet)上运行这些测试的解决方案Explorer,Safari)。通过Maven,我可以通过输入不同的浏览器值作为属性来创建不同的配置文件。我也打算在Hudson这样的持续集成服务器上运行它。

但是,现在,我面临着两难的局面。我可以让FireFox 4显示TestRunner,感谢本论坛的一些帮助,让插件使用Selenium Server 2.0。但是,当浏览器被激活时,TestRunner就会坐在那里,它不会自动在套件中运行测试。

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

请在下方查看我的POM文件的片段。

....
<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如下。

铬://src/content/TestRunner.html自动=真安培;多窗口=假安培; defaultLogLevel =信息&安培;的baseUrl = HTTP%3A%2F%2Flocalhost%3A5555%2F&安培; resultsUrl = HTTP://本地主机:5555 /硒 - 服务器/ postResults&安培;测试= HTTP%3A%2F%2Flocalhost%3A5555%2Fselenium服务器%2Ftests%2Fsuite.html

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

的http://本地主机:5555 /硒 - 服务器/核心/ TestRunner.html测试= ..%2Ftests%2Fsuite.html&安培; resultsUrl = HTTP%3A%2F%2Flocalhost:5555%2Fselenium - 服务器%2FpostResults

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

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

非常感谢您提前,

1 个答案:

答案 0 :(得分:0)

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

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

干杯,

相关问题