Selenium 自动化测试之道--Maven-TestNG
一、環(huán)境搭建
使用maven搭建testng測(cè)試框架
1.在apache官網(wǎng)下載并安裝maven,解壓maven壓縮包;
2.配置maven的環(huán)境變量 ?M2_HOME ?D:\Program Files\apache-maven-3.0.5
path ?%M2_HOME%\bin;
3. ?找的.m2文件壓縮包(里面有打包好的庫(kù)文件),解壓到這個(gè)路徑%userprofile%下的(C:\Administrator)
? ? ? ? ? ? 或者在maven安裝目錄下的/conf/settings.xml中添加maven中央倉(cāng)庫(kù)的阿里云鏡像:
<mirror><id>nexus-aliyun</id><name>Nexus aliyun</name><url>http://maven.aliyun.com/nexus/content/groups/public/</url><mirrorOf>central</mirrorOf> </mirror>? ? ? ? ? ? ? ? ? ?4.在eclipse中修改maven的安裝路徑:window---->preference---->maven----->installation---->add--->找到maven路徑--->ok
? ? ? ??在eclipse中修改maven的usersetting路徑:window---->preference---->maven----->usersetting---->點(diǎn)擊Browse--->找到D:\Program Files\apache-maven-3.0.5\conf\settings.xml--->ok
5.在eclipse中創(chuàng)建maven projec,注意選擇最后一個(gè)
6.在eclipse中安裝testNG插件:打開eclipse---->點(diǎn)擊help----> install new software,點(diǎn)擊ADD?
7.輸入name:testng?????,location:?http://beust.com/eclipse
?或者:?打開Eclipse,進(jìn)入?https://marketplace.eclipse.org/content/testng-eclipse,將鼠標(biāo)放置 Install 處,拖拉至 Eclipse 中---下載進(jìn)度條---confirm---下載進(jìn)度條---選擇i accept...點(diǎn)擊finish---下載進(jìn)度條---選擇yes---進(jìn)度條---選擇ok---eclipse自動(dòng)重啟。
驗(yàn)證:新建一個(gè) “Java Project”,右鍵 “Build Path” -> “Add Libraries” -> “TestNG”
運(yùn)行一段測(cè)試代碼:
import org.testng.annotations.*;public class SimpleTest {@BeforeClasspublic void setUp() {// code that will be invoked when this test is instantiated }@Test(groups = { "fast" })public void aFastTest() {System.out.println("Fast test");}@Test(groups = { "slow" })public void aSlowTest() {System.out.println("Slow test");} } View Code再或者下載testNG的離線包,將其解壓后feature中的org文件夾放到eclipse/feature中
8.檢查eclipse是否安裝了插件:右鍵點(diǎn)擊包名---> new ----->other ----->testng class(沒有安裝成功的話,找不到testNG)
9.修改pom.xml文件:1.百度maven,選擇maven repository;
2.打開maven repository官網(wǎng),搜selenium,點(diǎn)擊selenium java(基于Java語(yǔ)言),選擇版本2.53.1
3.復(fù)制XML代碼
?
轉(zhuǎn)載于:https://www.cnblogs.com/mimihuhudeliwu/p/9463906.html
總結(jié)
以上是生活随笔為你收集整理的Selenium 自动化测试之道--Maven-TestNG的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: KVM虚拟化查看虚拟机IP
- 下一篇: zip伪加密破解方法