Selenium2.47.1 + Maven3.3.9 + TestNG6.8.8

windows准备好以下环境
1、 Jdk,环境变量配置
2、 maven环境
3、 eclipse 开发工具 ,eclipse安装好testng插件

动手:
1、 Maven安装配置,参考我的博客:http://www.cnblogs.com/lincj/p/5470032.html

2、 新建个文件夹test,在cmd进入到test目录:
运行mvn archetype:generate
回车直到,看到:"Define value for groupId: :"停止
 输入groupID,格式:"com.test",回车
 输入artifactId,格式:"test",回车
 回车
输入package,格式:"com.test.test",回车  输入Y,回车 
看到BUILD SUCCESS,成功 maven工程创建完毕

3、工程做如下修改,把默认创建的src下目录全部删掉,在src下创建一个目录testScript

4、 进入test文件夹,有个pom.xml打开,

    <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.test</groupId>
<artifactId>test</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>test</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

把以上内容替换为:

     <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.test</groupId>
<artifactId>lincj_test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging> <name>lincj_test</name>
<url>http://maven.apache.org</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.47.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.8</version>
</dependency>
</dependencies> <build>
<sourceDirectory>${basedir}/src</sourceDirectory>
<testSourceDirectory>${basedir}/src</testSourceDirectory>
<plugins> <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<encoding>UTF-8</encoding>
</configuration> </plugin> <plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin> </plugins>
</build> </project>

5、在test文件夹下,新建一个批处理文件:build.bat
内容如下

@echo off
setlocal
call mvn eclipse:clean
call mvn -npu eclipse:eclipse -Dwtpversion=1.0 -DdownloadSources=true
pause
endloca

6、 打开eclipse,安装testng插件(可参考我的博客:http://www.cnblogs.com/lincj/p/5470903.html),如果已经安装跳过

7、打开eclipse—》 window—》Preferences,设置两个地方

Name:M2_REPO Path:C:/Documents and Settings/Administrator/.m2/repository 注:Path为Maven本地仓库

9、 重启eclipse—》import—》existing projects into workspace,导入项目"test" 项目
在test项目下创建testng文件,内容如下:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="test">
<test name="version" preserve-order="true">
<classes>
<class name="testScript.login">
<methods>
<include name="login" />
</methods>
</class>
</classes>
</test>
</suite>

关于testng.xml文件各种标签的意义大家自行上网上去查

10、 Maven是约定优于配置,把测试脚本创建在src/testScript下,创建以下脚本:login.java,代码如下:

package testScript;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; public class login { WebDriver driver; @Test
public void login(){
driver=new FirefoxDriver();
driver.get("http://www.baidu.com");
driver.quit();
}
}

11、到此项目搭建完成,可以通过dos窗口,进入test目录,运行:mvn install 或者在eclipse中右键项目选择maven->maven install

windows下 maven+selenium+testng项目搭建(七)的更多相关文章

  1. 2.在Jenkins中配置及执行 maven + selenium + testng项目

    1. 在Jenkins中配置Maven与Git 1)在系统管理>管理插件>可选插件 页面分别下载Git plugin 与 Maven Integration plugin插件,安装完成后再 ...

  2. eclipse下SpringMVC+Maven+Mybatis+MySQL项目搭建

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 接下来马上进入项目搭建 ...

  3. centos7下Maven Java selenium3环境搭建

    centos7下Maven Java selenium3环境搭建 一.Jdk安装 我这里用的是open-jdk. [adawang@localhost src]$ sudo yum search op ...

  4. [转]MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)

    MonkeyRunner在Windows下的Eclipse开发环境搭建步骤(兼解决网上Jython配置出错的问题)   网上有一篇shangdong_chu网友写的文章介绍如何在Eclipse上配置M ...

  5. Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建(转)

    这篇文章主要讲解使用eclipse对Spirng+SpringMVC+Maven+Mybatis+MySQL项目搭建过程,包括里面步骤和里面的配置文件如何配置等等都会详细说明. 如果还没有搭建好环境( ...

  6. 在Windows下用Eclipse+CDT+MinGW搭建C++开发平台

    本文提供了在Windows下用Eclipse+CDT+MinGW搭建C / C++开发平台的方法, 测试平台为Windows XP Sp2 CHS.   以下软件均为Windows平台下的版本. 1. ...

  7. windows下vue.js开发环境搭建教程

    这篇文章主要为大家详细介绍了windows下vue.js开发环境搭建教程,具有一定的参考价值,感兴趣的小伙伴们可以参考一下 最近,vue.js越来越火.在这样的大浪潮下,我也开始进入vue的学习行列中 ...

  8. redis在Windows下以后台服务一键搭建集群(多机器)

    redis在Windows下以后台服务一键搭建集群(多机器) 一.概述 此教程介绍如何在windows系统中多台机器之间布置redis集群,同时要以后台服务的模式运行.布置以脚本的形式,一键完成.多台 ...

  9. redis在Windows下以后台服务一键搭建集群(单机--伪集群)

    redis在Windows下以后台服务一键搭建集群(单机--伪集群) 一.概述 此教程介绍如何在windows系统中同一台机器上布置redis伪集群,同时要以后台服务的模式运行.布置以脚本的形式,一键 ...

随机推荐

  1. C 语言设计坦克大战(未完成)

    //坦克大战 //0.提示界面 //1.边框 //2.指定位置显示自己的坦克 //3.己方坦克随着方向键动起来 //getasynkeustae //Sleep(毫秒) //减少闪烁 //不闪烁Set ...

  2. CornerStone使用跳坑总结

    Cornerstone是专门为Mac用户设计的Subversion(SVN)的控制,使版本控制更加透明.cornerstone根Xcode相比,能够更好的忽略文件,所以除了项目经理第一次初始化项目的时 ...

  3. Bootstrap标签页(Tab)插件事件

    事件 下表列出了标签页(Tab)插件中要用到的事件.这些事件可在函数中当钩子使用. 事件 描述 实例 show.bs.tab 该事件在标签页显示时触发,但是必须在新标签页被显示之前.分别使用 even ...

  4. 01_3_创建一个Servlet

    01_3_创建一个Servlet 1.创建一个Servlet import java.io.IOException; import java.io.PrintWriter; import javax. ...

  5. HomeKit开发(一)

    需求:因为公司的生产硬件需要进入苹果的HomeKit市场,因此需要一款供苹果审核的APP(功能:苹果的家庭软件的功能+公司的硬件支持的功能特有功能)需求驱动开发:最近做了一款苹果HomeKit的软件 ...

  6. #ifdef #else #endif #fi #ifndef 的用法

    预处理就是在进行编译的第一遍词法扫描和语法分析之前所作的工作.说白了,就是对源文件进行编译前,先对预处理部分进行处理,然后对处理后的代码进行编译.这样做的好处是,经过处理后的代码,将会变的很精短.   ...

  7. 八皇后问题(DFS)

    题目描述: 要在国际象棋棋盘中放八个皇后,使任意两个皇后都不能互相吃,皇后能吃同一行.同一列,同一对角线上(两个方向的对角线)的任意棋子.现在给一个整数n(n<=92),输出前n种的摆法. 输入 ...

  8. RabbitMQ学习(二):Java使用RabbitMQ要点知识

    转  https://blog.csdn.net/leixiaotao_java/article/details/78924863 1.maven依赖 <dependency> <g ...

  9. vue组件:canvas实现图片涂鸦功能

    方案背景 需求 需要对图片进行标注,导出图片. 需要标注N多图片最后同时保存. 需要根据多边形区域数据(区域.颜色.名称)标注. 对应方案 用canvas实现涂鸦.圆形.矩形的绘制,最终生成图片bas ...

  10. 【laravel】Laravel 5 TokenMismatchException on PHP 5.6.9

    When I realized this was only happening in IE and Chrome, but not Firefox, it led me to the fix. The ...