Selenium+IDEA+Maven+TestNG環境搭建

1、安裝jdk。html

jdk下載地址:http://www.oracle.com/technetwork/java/javase/downloads/index.htmljava

 

具體環境配置見:Jmeter安裝及環境配置chrome

2、Maven安裝、環境配置apache

一、Maven下載:http://maven.apache.org/download.cgioracle

二、Maven環境配置maven

 1>在系統變量內添加環境變量 M2_HOME(或者MAVEN_HOME),值爲解壓後的目錄,如C:\Program Files\Java\apache-maven-3.3.3.工具

 2>在系統變量內Path中添加%M2_HOME%\binpost

3>win+R,運行cmd命令行:mvn -v    檢查是否安裝成功,以下圖即成功!開發工具

 

3、準備Intellij IDEA開發工具url

Intellij IDEA開發工具破解見:http://www.cnblogs.com/lxj-dream/p/8653473.html

4、在Maven項目中添加Selenium和TestNG相關jar包的依賴

1. 在IDEA中新建一個Maven項目。

2.搜索到如下相關jar包的group ID, artifact ID, version等相關信息,並將此添加到pom.xml文件的dependencies中(項目中使用到的其餘jar包也可至該網址上搜索到並添加至pom.xml文件):

Selenium-firefox-driver, selenium-chrome-driver, selenium-ie-driver, selenium-support, testng

 <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-chrome-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-chrome-driver</artifactId>
        <version>3.11.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-firefox-driver -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-firefox-driver</artifactId>
        <version>3.11.0</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.testng/testng -->
    <dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.14.2</version>
        <scope>test</scope>
    </dependency>

    <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-support -->
    <dependency>
        <groupId>org.seleniumhq.selenium</groupId>
        <artifactId>selenium-support</artifactId>
        <version>3.11.0</version>
    </dependency>
相關文章
相關標籤/搜索