如何启动Selenium网格Java Maven安装程序的服务器 [英] How to start server for Selenium grid Java Maven setup

查看:104
本文介绍了如何启动Selenium网格Java Maven安装程序的服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Maven Java设置了Selenium框架.因此所有依赖项都存储在POM.xml中 在这里我感到疑惑..如何启动服务器java -jar selenium-server-standalone-2.18.0.jar -role hub ..我是否应该再次将该jar放在某个文件夹中,并且应该从该路径开始?还是应该转到Maven Dependencies文件夹(.m2 \ Repositories)?

I setup Selenium framework with Maven Java. So all dependencies are storing in POM.xml Here I got doubt.. How to start server java -jar selenium-server-standalone-2.18.0.jar -role hub .. Should I place this jar again in some folder and should I start from that path ? Or shall I go to Maven Dependencies folder (.m2\Repositories) ?

有人可以建议我吗?

如果问题不清楚,请回信.我将以不同的方式进行解释.

If question is not clear please ping back. I will explain in different way.

谢谢 拉朱

推荐答案

从Maven运行Selenium Grid可能不是一个好主意.这取决于您要做什么以及如何做.

Running Selenium Grid from Maven might be not a good idea; it depends on what and how you are going to do.

通常,您将在几个/许多不同的环境中并行运行Selenium测试,这会花费大量资源.当您从Maven启动进程时,它们在其主线程(作为子线程)中运行,因此其资源仅限于Maven的配置.这取决于您的机器和配置,但是在一台普通机器上从Maven启动网格并并行运行一些Selenium测试(集线器和几个节点,每个节点有5个实例)可能会使Maven挂起的记忆.为了避免这种情况,您可以调整配置,依次运行测试(不是并行运行,仅一个节点),等等,但又要注意:这取决于您要执行的操作和方式,也许您应该考虑使用其他方式运行硒测试.

Normally, you will run Selenium tests in parallel against several/many different environments and this has a considerable resource cost. When you start processes from Maven, they run within its main thread (as child threads), therefore having their resources limited to Maven's configuration. It depends on your machine/s and configuration/s, but starting your grid from Maven and running a few Selenium tests in parallel (the hub and a couple of nodes with 5 instances each) on one average machine will likely make Maven hang for lack of memory. To avoid it, you can adjust the configuration, run the tests sequentially (not in parallel, one node only), etc., but again: it depends on what and how you want to do and perhaps you should consider other ways of running your Selenium tests.

尽管如此,如果您只想尝试Selenium Grid的工作方式,或者只是运行一些特定测试,则可以使用maven-antrun-plugin并像这样启动集线器和节点:

Nevertheless, if you just want to try how Selenium Grid works or it's just a couple of some specific tests that will be running, you can use maven-antrun-plugin and start your hub and nodes like this:

<plugin>
 <groupId>org.apache.maven.plugins</groupId>
 <artifactId>maven-antrun-plugin</artifactId>
 <version>1.7</version>
 <executions>
    <execution>
        <phase>pre-integration-test</phase> <!-- your Selenium tests should run in integration phase -->
        <configuration>
            <target>
                <java classname="org.openqa.grid.selenium.GridLauncher"
                      classpathref="maven.test.classpath"
                      failonerror="true"
                      fork="false">
                    <arg line="-role hub"/>
                </java>
                <java classname="org.openqa.grid.selenium.GridLauncher"
                      classpathref="maven.test.classpath"
                      failonerror="true"
                      fork="false">
                    <arg line="-role node
                               -browser 'browserName=firefox,version=19.0,maxInstances=3'
                               -browser 'browserName=internet explorer 64bits,version=9.0,maxInstances=2'
                               -hub http://localhost:4444/grid/register 
                               -port 5555 
                               -timeout 40000"/>
                </java>
                <java classname="org.openqa.grid.selenium.GridLauncher"
                      classpathref="maven.test.classpath"
                      failonerror="true"
                      fork="false">
                    <arg line="-role node
                               -browser 'browserName=chrome,version=24.0.1312.56,maxInstances=3'
                               -browser 'browserName=internet explorer 64bits,version=9.0,maxInstances=2'
                               -hub http://localhost:4444/grid/register 
                               -port 5556 
                               -timeout 40000"/>
                </java>
            </target>
        </configuration>
        <goals>
            <goal>run</goal>
        </goals>
    </execution>
</executions>
</plugin>

您的pom.xml中应该具有此依赖项:

Your should have this dependency in your pom.xml:

     <dependency>
        <groupId>org.seleniumhq.selenium.server</groupId>
        <artifactId>selenium-server-standalone</artifactId>
        <version>2.30.0</version>
        <scope>test</scope>
    </dependency>

这篇关于如何启动Selenium网格Java Maven安装程序的服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆