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

发布于 2024-11-13 11:06:11 字数 3485 浏览 5 评论 0原文

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

然而,现在我面临着一个两难的境地。感谢这个论坛的一些帮助,通过让插件使用 Selenium Server 2.0,我能够让 FireFox 4 显示 TestRunner。但是,当浏览器被激活时,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 如下。

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

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

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

预先非常感谢你,

胡安

I am trying to run a series of HTML selenium tests using the selenese command through Selenium Maven plugin (version 1.1) in the hopes of coming up with a solution to able to run these tests across different browsers (Chrome, Firefox, Internet Explorer, Safari). Through Maven I would be able to create different profiles by entering different browser values as properties. I am also planning on running this on a continuous integration server like Hudson down the road.

However, right now, I am faced with a dilemma. I am able to get FireFox 4 to display the TestRunner thanks to some help from this forum by getting the plugin to use Selenium Server 2.0. However, when the browser is activated, TestRunner just sits there and it doesn't run the tests in the suite automatically.

If I run the test suite in Selenium IDE, it runs perfectly fine, so I know there is no issue with the test suite. I have also run the test suite using the IE browser option and it ran fine without any issues. I have also confirmed that by downgrading to Firefox 3.6 it will run, so I am fairly certain that this has to do with Firefox 4 and the Maven Selenium plugin.

Please see a snippet of my POM file below.

....
<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>
....

I run the script using the Maven command mvn integration-test, and as I mentioned earlier it brings up the TestRunner page, but the tests do not run automatically. The URL that it uses is as follows.

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

What I find strange is that when I change the above URL to the following URL, it runs the tests automatically, which is exactly what I want.

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

My question is there a way to get the Maven-Selenium plugin to run automatically for Firefox 4 by using the URL that works? Is there some setup that I would need to configure?

If the answer is no, then what would be the most convenient way to run Selenium HTML scripts so that they are running independently of the browser. Also, would I be able to run those tests on a continuous integration server, like Hudson, after our builds are complete and code is deployed?

Thank you very much in advance,

Juan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

恬淡成诗 2024-11-20 11:06:11

我想通了这个问题。我只是简单升级到Selenium Server 2.0b3神器,就运行顺利了。显然,2.0a7 于 2010 年 10 月发布,而 2.0b3 于 2011 年 3 月发布,与 Firefox 4 发布时间一致。

测试现在在 Firefox 上自动运行,正如它们应该的那样。我希望这对遇到同样问题的其他人有所帮助。

干杯,

胡安

I figured out the issue. I simply upgraded to the Selenium Server 2.0b3 artifact and it worked smoothly. Apparently, 2.0a7 was released in October 2010 whereas 2.0b3 was released in March 2011 which coincides with the Firefox 4 release.

The tests are now running automatically on firefox as they should. I hope this helps anyone else who is experiencing the same issue.

Cheers,

Juan

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文