user2454672
user2454672

Reputation: 21

For Selenium WebDriver - Maven and initial pom.xml configuration

I am new for Selenium Webdriver. When I start with the tool I came to know there are two things necessary to start with: Maven and pom.xml. But I didn't find the details on these things. Could anyone let know what is the meaning of these files and how do I create them.

Also I would be thankful, if someone could share some knowledge on the Selenium WebDriver like how do I start with the tool, and how to write a scripts - I have Java knowledge, so I can prefer to that language.

Thanks in advance :) awaiting to learn about the tools :)

Upvotes: 2

Views: 7177

Answers (2)

Ittiel
Ittiel

Reputation: 1224

Maven and it's pom.xml are not a must (but a recommended solution). Their role in the process is just to add the selenium jar to your project.

You can manually add the Selenium jar file to your project by downloading the jar from http://docs.seleniumhq.org/download/ and adding it to your classpath.

OR, https://code.google.com/p/selenium/downloads/list?can=1&q=&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount

Selenium site has also the relevant documentation to get you started - http://docs.seleniumhq.org/docs/03_webdriver.jsp

Maven: http://maven.apache.org/

Upvotes: 2

djangofan
djangofan

Reputation: 29669

I would recommend starting with a pom.xml that looks like this. You will have to manually create the directories src/main/java, src/test/java, and src/test/resources, but after do so, if you run "mvn clean build", it will refresh and give you the proper perspective in Eclipse IDE. Maven can be confusing on a new project because it doesn't auto generate those directories. :

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>SeleniumMavenExample</groupId>
  <artifactId>SeleniumMavenExample</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <properties>
    <selenium.version>2.39.0</selenium.version>
    <maven.surefire.plugin.version>2.16</maven.surefire.plugin.version>
    <testng.version>6.8.7</testng.version>
  </properties>
  <build>
    <directory>target</directory>
    <outputDirectory>target/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>target/test-classes</testOutputDirectory>
    <sourceDirectory>src/main/java</sourceDirectory>
    <testSourceDirectory>src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven.surefire.plugin.version}</version>
        <configuration>
          <showSuccess>true</showSuccess>
          <suiteXmlFiles>
            <suiteXmlFile>src/test/resources/testng.xml</suiteXmlFile>
          </suiteXmlFiles>
          <configuration>
            <systemPropertyVariables>
              <build-name>${surefire.testng.build}</build-name>
            </systemPropertyVariables>
            <groups>${surefire.testng.groups}</groups>
            <testFailureIgnore>true</testFailureIgnore>
          </configuration>
        </configuration>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.apache.metamodel</groupId>
      <artifactId>MetaModel-full</artifactId>
      <version>4.0.0-incubating</version>
    </dependency>
    <dependency>
      <groupId>org.testng</groupId>
      <artifactId>testng</artifactId>
      <version>${testng.version}</version>
    </dependency>
    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>16.0.1</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>1.7.6</version>
    </dependency>   
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <version>${selenium.version}</version>
    </dependency>
    <dependency>
      <groupId>net.lightbody.bmp</groupId>
      <artifactId>browsermob-proxy</artifactId>
      <version>2.0-beta-9</version>
    </dependency> 
  </dependencies>
</project>

Upvotes: 0

Related Questions