创建maven工程 用做selenium webDriver + TestNg的UI自动化

工具:Eclipse

在eclipse安装插件:

maven插件地址:http://download.eclipse.org/technology/m2e/releases

TestNg插件地址:http://beust.com/eclipse

selenium下载地址:http://docs.seleniumhq.org/download/

步骤:

1、新建maven工程

(simple project对新手有很好的指导作用)

 

3.pom.xml文件里增加selenium及其他相应的配置

<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>com.xxx.app</groupId>
  <artifactId>integratedapp</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>integratedapp</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
    </dependency>
    
    <dependency>
	<groupId>org.seleniumhq.selenium</groupId>
	<artifactId>selenium-firefox-driver</artifactId>
	<version>2.25.0</version>
</dependency>
            
 <dependency>  
  <groupId>org.testng</groupId>  
  <artifactId>testng</artifactId>  
  <version>6.1.1</version>  
</dependency> 
            
 <dependency>  
    <groupId>mysql</groupId>  
    <artifactId>mysql-connector-java</artifactId>  
    <version>5.1.10</version>  
</dependency> 

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-java</artifactId>
        <version>2.41.0</version>
    </dependency>

    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-server</artifactId>
        <version>2.41.0</version>
    </dependency>  
  </dependencies>
</project>

  配置完成后,Eclipse会自动编译,将pom里涉及的相关jar下载到本地的classpath下

 

3. 如果不使用maven工程,则需要手动集成selenium

右键工程-〉Build Path-->Link source-->Browse,选择selenium的文件夹

对其下的三个jar依次操作:右键->Build Path->Add Build Path

 

 

 

posted on 2014-05-12 15:16  娇娇家的美衣阁  阅读(1078)  评论(0编辑  收藏  举报

导航