我想通过Selenium命令通过Selenium Maven插件(1.1版)运行一系列的HTML selenium测试,希望能够提出一个解决方案能够跨不同浏览器(Chrome,Firefox,Internet Explorer,Safari)运行这些测试。通过Maven,我可以通过输入不同的浏览器值作为属性来创建不同的配置文件。我也计划在像Hudson这样的持续集成服务器上运行它。当运行Selenium 2.0时,TestRunner未自动运行使用Selenium-Maven插件进行的HTML Selenese测试
但是,现在我面临着一个两难的局面。我能够让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集成测试脚本,正如我前面提到的它带来了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,它会自动运行测试,这正是我想要的。
的http://本地主机:5555 /硒 - 服务器/核心/ TestRunner.html测试= ..%2Ftests%2Fsuite.html & resultsUrl = HTTP%3A%2F%2Flocalhost:5555%2Fselenium服务器% 2FpostResults
我的问题是有没有办法让Maven-Selenium插件自动运行Firefox 4,通过使用工作的URL?有一些设置需要配置吗?
如果答案是否定的,那么运行Selenium HTML脚本以使它们独立于浏览器运行的最便捷方式是什么?另外,在构建完成并部署代码之后,我是否能够在持续集成服务器(如Hudson)上运行这些测试?
非常感谢你提前,
胡安