2

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) ?

Can any one suggest me ?

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

Thanks Raju

HemChe
  • 2,249
  • 1
  • 21
  • 33
Raju
  • 137
  • 2
  • 4
  • 15

1 Answers1

8

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

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.

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>

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>
Sergio Pelin
  • 874
  • 7
  • 22
  • Hi Thank you for your suggestion I really thank full for your suggestion. – Raju Apr 09 '13 at 11:46
  • No I have not yet tried this one. But still I am in process to setup a Hybrid frame work with Maven, Selenium grid, Testng. Do think is it good combination ? Can you give your suggestion ? – Raju Apr 10 '13 at 11:30
  • I never worked with Hybrid, don't know. As for Selenium Grid + TestNG it is a totally valid choice, many developers use it. I hope my answer helps you. If so, remember to vote it. If any problems, don't doubt to tell me. – Sergio Pelin Apr 10 '13 at 13:19