selenium+testng+java环境搭建

2017-11-16  本文已影响0人  十九以北

1)配置java环境:

安装jdk、jre,配置环境变量

•安装eclipse/myeclipse

2)下载驱动包

•从selenium官网下载webdriver针对java的驱动文件包(selenium-java-2.44.0.zip),解压缩

3)导入selenium驱动包

•启动eclipse,配置webdriver工程

•a、file—new—java projeck,next

•b、切换libraries选项卡,点击add external jars,选择(2)中解压缩的的文件夹内的selenium-java-2.44.0.jar,打开

•c、点击add external jars,选择(2)中解压缩的的文件夹内的lib中所有的jar包,打开

•d、如果使用junit,点击add library按钮,选项junit,next,选择junit4,finis

(4)安装浏览器驱动

•Chrome浏览器运行脚本。

•准备工作:a.安装Chrome浏览器. b.从Selenium官网下载指定版本的chromedriver.exe

火狐不需要安装

(5)TestNG安装:

•在线安装:

•Eclipse: 选择菜单栏中Help/Install new software, 然后在弹出窗口中输入name = testNG, url= http://www.beust.com/eclipse.

•离线安装:

•a.在eclipse/MyEclipse的安装目录...\dropins文件夹中放入org.testng.eclipse_5.12.0.6.jar,然后重启Eclipse。

•b.在project的build path中将testng-5.12.jar添加到对应的lib中。若是Selenium的lib包中已经包含testNG的jar包,则可忽略步骤b.

上一篇下一篇

猜你喜欢

热点阅读