Saturday, August 14, 2010

selenium with pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</
modelVersion>
    <groupId>com.itgrids</groupId>
    <artifactId>SampleTest1</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <name>Selenium Functional Tests</name>
    <url>http://www.salesforce.com</url>
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium.client-drivers</groupId>
            <artifactId>selenium-java-client-driver</artifactId>
            <version>1.0.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium.server</groupId>
            <artifactId>selenium-server</artifactId>
            <version>1.0.1</version>
            <scope>test</scope>
        </dependency>
    <dependency>
          <groupId>org.testng  </groupId>
          <artifactId>testng</artifactId>
          <version>5.8</version>
          <scope>test</scope>
          <classifier>jdk15</classifier>
        </dependency>
     </dependencies>
    <build>
 
        <plugins>
       
         <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
           
             <!-- Selenium Maven Plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
       <artifactId>selenium-maven-plugin</artifactId>
        <version>1.0</version>
                <executions>
                    <execution>
                     <id>copy</id>
                        <phase>pre-integration-test</phase>
                        <goals>
                            <goal>start-server</goal>
                        </goals>
                        <configuration>
                            <!-- <artifactItems>
                                <artifactItem>
                                    <groupId>org.seleniumhq.selenium.server</groupId>
                                    <artifactId>selenium-server</artifactId>
                                    <version>1.0.1</version>
                                    <type>jar</type>
                                    <outputDirectory></outputDirectory>
                                    <destFileName>selenium-server.jar</destFileName>
                                </artifactItem>
                            </artifactItems> -->
                            <background>true</background>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
            <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>start-selenium</id>
                        <phase>pre-integration-test</phase>
                        <configuration>
                            <tasks>
                                <echo taskname="selenium" message=" Starting Selenium Remote Control                        "/>
                                <java jar="/selenium-server.jar" fork="yes" spawn="true">
                                 <arg line="-firefoxProfileTemplate ${profiles} -singleWindow -ensureCleanSession" />
                              </java>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>stop-selenium</id>
                        <phase>post-integration-test</phase>
                        <configuration>
                            <tasks>
                                <echo taskname="selenium" message=" Shutting down Selenium Remote Control"/>
                                <echo taskname="selenium" message=" DGF Errors during shutdown are expected"/>
                                <get taskname="selenium"
                                     src="http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer"
                                     dest="result.txt" ignoreerrors="true"/>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
           
            <!-- Surefire plugin -->
   
   <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
       
        <executions>
            <execution>
                <phase>integration-test</phase>
                <goals>
                    <goal>test</goal>
                </goals>
                <configuration>
                <excludes>
                    <exclude>**/*.java</exclude>
                  </excludes>
                    <skip>false</skip>
                </configuration>
            </execution>
        </executions>
        <configuration>
            <suiteXmlFiles>
                <suiteXmlFile>
                    **/*.xml
                  </suiteXmlFile>
            </suiteXmlFiles>
            <parallel>true</parallel>
            <threadCount>10</threadCount>
        </configuration>
    </plugin>

        </plugins>
    </build>
   
     <reporting>
    <outputDirectory>SampleTest1/reports</outputDirectory>
  </reporting>
   
    <repositories>
        <repository>
            <id>openqa</id>
            <url>http://maven.openqa.org</url>
        </repository>
    </repositories>
    <properties>
        <selenium-version>1.0.1</selenium-version>
    </properties>
</project>

1 comment:

  1. Thank you for the info. It sounds pretty user friendly. I guess I’ll pick one up for fun. thank u


    Selenium Training in Chennai

    ReplyDelete